From a5a14e23307734e414c0f60f1873caaa5c741d9f Mon Sep 17 00:00:00 2001 From: Christian Schmitt <chris@ilovelinux.de> Date: Mon, 17 Oct 2011 16:53:52 +0200 Subject: [PATCH] Initialize variables and remove unused ones --- src/Airports/GenAirports850/airport.cxx | 2 -- src/Airports/GenAirports850/apt_math.cxx | 2 +- src/Airports/GenAirports850/apt_surface.cxx | 1 - src/Airports/GenAirports850/closedpoly.cxx | 19 +++------- src/Airports/GenAirports850/helipad.cxx | 2 +- src/Airports/GenAirports850/linearfeature.cxx | 21 +++++------ src/Airports/GenAirports850/object.cxx | 2 +- src/Airports/GenAirports850/parser.cxx | 35 +++++++++---------- src/Airports/GenAirports850/runway.cxx | 2 +- 9 files changed, 33 insertions(+), 53 deletions(-) diff --git a/src/Airports/GenAirports850/airport.cxx b/src/Airports/GenAirports850/airport.cxx index f68cdb64..f91e410e 100644 --- a/src/Airports/GenAirports850/airport.cxx +++ b/src/Airports/GenAirports850/airport.cxx @@ -348,12 +348,10 @@ void Airport::BuildBtg(const string& root, const string_list& elev_src ) texparams_list line_tps; int i, j, k; - char buf[120]; // For debugging output Point3D p; // parse main airport information double apt_lon = 0.0, apt_lat = 0.0; - int rwy_count = 0; struct timeval build_start; struct timeval build_end; diff --git a/src/Airports/GenAirports850/apt_math.cxx b/src/Airports/GenAirports850/apt_math.cxx index ea5be0ef..ceb9c1fe 100644 --- a/src/Airports/GenAirports850/apt_math.cxx +++ b/src/Airports/GenAirports850/apt_math.cxx @@ -44,7 +44,7 @@ TGPolygon gen_wgs84_area( Point3D origin, // move to the +l end/center of the runway Point3D ref = origin; - double lon, lat, r; + double lon = 0, lat = 0, r = 0; geo_direct_wgs_84 ( alt_m, ref.lat(), ref.lon(), length_hdg, length_m / 2.0 - displ2, &lat, &lon, &r ); ref = Point3D( lon, lat, 0.0 ); diff --git a/src/Airports/GenAirports850/apt_surface.cxx b/src/Airports/GenAirports850/apt_surface.cxx index e29f81bb..c0362e0e 100644 --- a/src/Airports/GenAirports850/apt_surface.cxx +++ b/src/Airports/GenAirports850/apt_surface.cxx @@ -342,7 +342,6 @@ static ColumnVector qr_method( Real* y, QRZ(X1, U); QRZ(X1, Y1, M); // Y1 now contains resids ColumnVector A = U.i() * M; ColumnVector Fitted = X * A; - Real ResVar = sum_square(Y1) / (nobs-npred1); // get variances of estimates U = U.i(); DiagonalMatrix D; D << U * U.t(); diff --git a/src/Airports/GenAirports850/closedpoly.cxx b/src/Airports/GenAirports850/closedpoly.cxx index 00840dd9..e35c65cb 100644 --- a/src/Airports/GenAirports850/closedpoly.cxx +++ b/src/Airports/GenAirports850/closedpoly.cxx @@ -154,8 +154,6 @@ void ClosedPoly::ConvertContour( BezContour* src, point_list *dst ) Point3D cp1; Point3D cp2; - int start, end, inc; - int curve_type = CURVE_LINEAR; int i; @@ -304,11 +302,9 @@ void ClosedPoly::ConvertContour( BezContour* src, point_list *dst ) void ExpandPoint( Point3D *prev, Point3D *cur, Point3D *next, double expand_by, double *heading, double *offset ) { - int turn_direction; - bool reverse_dir = false; double offset_dir; double next_dir; - double az1, az2; + double az2; double dist; SG_LOG(SG_GENERAL, SG_DEBUG, "Find average angle for contour: prev (" << *prev << "), " @@ -348,12 +344,11 @@ void ClosedPoly::ExpandContour( point_list& src, TGPolygon& dst, double dist ) point_list expanded_boundary; Point3D prevPoint, curPoint, nextPoint; double theta; - double expand_by; - double expanded_x, expanded_y; + double expanded_x = 0, expanded_y = 0; Point3D expanded_point; - double h1, h2, h3; - double o1, o2, o3; + double h1; + double o1; double az2; int i; @@ -468,9 +463,7 @@ osg::DrawArrays* ClosedPoly::CreateOsgPrimitive( point_list contour, osg::Vec3Ar // finish the poly - convert to TGPolygon, and tesselate int ClosedPoly::Finish() { - BezContour* src_contour; point_list dst_contour; - BezNode* node; // error handling if (boundary == NULL) @@ -507,8 +500,6 @@ int ClosedPoly::Finish() int ClosedPoly::BuildOsg( osg::Group* airport ) { - BezContour* contour; - BezNode* node; osg::Geode* geode_pave; // has the stateset, and geometry for this poly osg::Geometry* pavement; osg::StateSet* ss_pave; // just a simple stateset for now @@ -516,7 +507,6 @@ int ClosedPoly::BuildOsg( osg::Group* airport ) osg::Vec4Array* col_pave; // just grey for now... osg::Vec3Array* v_pave; // ALL verticies (boundary and holes) osg::DrawArrays* primitive; // an index array for boundary / hole - int num_verts; // number of verticies in a contour int i; // ? if ( pre_tess.contours() ) @@ -593,7 +583,6 @@ int ClosedPoly::BuildBtg( float alt_m, superpoly_list* rwy_polys, texparams_list { TGPolygon base, safe_base; string material; - int j, k; if (is_pavement) { diff --git a/src/Airports/GenAirports850/helipad.cxx b/src/Airports/GenAirports850/helipad.cxx index 32898a0e..8fbd9812 100644 --- a/src/Airports/GenAirports850/helipad.cxx +++ b/src/Airports/GenAirports850/helipad.cxx @@ -42,7 +42,7 @@ superpoly_list Helipad::gen_helipad_lights(void){ point_list c_lights; c_lights.clear(); point_list c_normals; c_normals.clear(); - double lat2, lon2, az2; + double lat2 = 0, lon2 = 0, az2; // Create a circle of lights approx. where the white circle is for (int deg=0; deg<360; deg+=10){ diff --git a/src/Airports/GenAirports850/linearfeature.cxx b/src/Airports/GenAirports850/linearfeature.cxx index 0fcd9f26..fef00657 100644 --- a/src/Airports/GenAirports850/linearfeature.cxx +++ b/src/Airports/GenAirports850/linearfeature.cxx @@ -31,7 +31,6 @@ void LinearFeature::ConvertContour( BezContour* src ) int curve_type = CURVE_LINEAR; Marking* cur_mark = NULL; Lighting* cur_light = NULL; - double lgt_dist = 0.0f; int i; SG_LOG(SG_GENERAL, SG_DEBUG, " LinearFeature::ConvertContour - Creating a contour with " << src->size() << " nodes"); @@ -275,10 +274,10 @@ Point3D LinearFeature::OffsetPointMiddle( Point3D *prev, Point3D *cur, Point3D * { double offset_dir; double next_dir; - double az1, az2; + double az2; double dist; double theta; - double pt_x, pt_y; + double pt_x = 0, pt_y = 0; SG_LOG(SG_GENERAL, SG_DEBUG, "Find average angle for contour: prev (" << *prev << "), " "cur (" << *cur << "), " @@ -376,9 +375,9 @@ Point3D LinearFeature::OffsetPointMiddle( Point3D *prev, Point3D *cur, Point3D * Point3D LinearFeature::OffsetPointFirst( Point3D *cur, Point3D *next, double offset_by ) { double offset_dir; - double az1, az2; + double az2; double dist; - double pt_x, pt_y; + double pt_x = 0, pt_y = 0; SG_LOG(SG_GENERAL, SG_DEBUG, "Find OffsetPoint at Start : cur (" << *cur << "), " "next (" << *next << ")" ); @@ -405,9 +404,9 @@ Point3D LinearFeature::OffsetPointFirst( Point3D *cur, Point3D *next, double off Point3D LinearFeature::OffsetPointLast( Point3D *prev, Point3D *cur, double offset_by ) { double offset_dir; - double az1, az2; + double az2; double dist; - double pt_x, pt_y; + double pt_x = 0, pt_y = 0; SG_LOG(SG_GENERAL, SG_DEBUG, "Find OffsetPoint at End : prev (" << *prev << "), " "cur (" << *cur << ")" ); @@ -447,14 +446,12 @@ int LinearFeature::Finish() double dist; double az2; double last_end_v; - double width; + double width = 0; int i, j; string material; - int mat_idx = 0; double cur_light_dist = 0.0f; - double light_delta; - double intpart; - double pt_x, pt_y; + double light_delta = 0; + double pt_x = 0, pt_y = 0; // create the inner and outer boundaries to generate polys diff --git a/src/Airports/GenAirports850/object.cxx b/src/Airports/GenAirports850/object.cxx index 268bf81e..0c08d7c3 100644 --- a/src/Airports/GenAirports850/object.cxx +++ b/src/Airports/GenAirports850/object.cxx @@ -17,7 +17,7 @@ void LightingObj::BuildBtg( int alt_m, superpoly_list* lights ) Point3D ref; - double lon2, lat2, r; + double lon2 = 0, lat2 = 0, r; double left_hdg = heading - 90.0; ref.setlat( lat ); diff --git a/src/Airports/GenAirports850/parser.cxx b/src/Airports/GenAirports850/parser.cxx index 6175b79c..1b58252e 100644 --- a/src/Airports/GenAirports850/parser.cxx +++ b/src/Airports/GenAirports850/parser.cxx @@ -102,7 +102,7 @@ void Parser::AddAirport( string icao ) long Parser::FindAirport( string icao ) { char line[2048]; - long cur_pos; + long cur_pos = 0; bool found = false; ifstream in( filename.c_str() ); @@ -141,19 +141,18 @@ long Parser::FindAirport( string icao ) void Parser::AddAirports( long start_pos, float min_lat, float min_lon, float max_lat, float max_lon ) { - Airport* airport = NULL; - char line[2048]; - char* def; - long cur_pos; - long cur_apt_pos; - string cur_apt_name; - char* tok; - int code; - bool match; - bool done; - - done = false; - match = false; + char line[2048]; + char* def; + long cur_pos; + long cur_apt_pos; + string cur_apt_name; + char* tok; + int code; + bool match; + bool done; + + done = false; + match = false; // start from current position, and push all airports where a runway start or end // lies within the given min/max coordinates @@ -310,7 +309,6 @@ void Parser::AddAirports( long start_pos, float min_lat, float min_lon, float ma void Parser::Parse() { char tmp[2048]; - bool done = false; int i; struct timeval parse_start; struct timeval parse_end; @@ -318,7 +316,6 @@ void Parser::Parse() struct timeval build_time; struct timeval clean_time; struct timeval triangulation_time; - time_t curtime; ifstream in( filename.c_str() ); if ( !in.is_open() ) @@ -377,9 +374,9 @@ BezNode* Parser::ParseNode( int type, char* line, BezNode* prevNode ) int feat_type1, feat_type2; BezNode *curNode = NULL; - bool hasCtrl; - bool close; - bool term; + bool hasCtrl = false; + bool close = false; + bool term = false; bool hasFeat1 = false; bool hasFeat2 = false; int numParams; diff --git a/src/Airports/GenAirports850/runway.cxx b/src/Airports/GenAirports850/runway.cxx index 9301b4fe..039fbb3e 100644 --- a/src/Airports/GenAirports850/runway.cxx +++ b/src/Airports/GenAirports850/runway.cxx @@ -60,7 +60,7 @@ int Runway::BuildOsg ( osg::Group* airport ) double az1, az2, dist; // rectangle verticies - double v0_lat, v0_lon, v1_lat, v1_lon, v2_lat, v2_lon, v3_lat, v3_lon; + double v0_lat = 0, v0_lon = 0, v1_lat = 0, v1_lon = 0, v2_lat = 0, v2_lon = 0, v3_lat = 0, v3_lon = 0; // Create a node for the runway osg::Geode* geode = new osg::Geode();