From: ThorstenB Date: Sat, 13 Oct 2012 15:59:47 +0000 (+0200) Subject: Fix some compiler warnings. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=076bbb84871952b7dfc791440d710748736389cb;p=flightgear.git Fix some compiler warnings. Unused vars, loss of precision, bool type conversions. --- diff --git a/src/Airports/dynamicloader.cxx b/src/Airports/dynamicloader.cxx index 79fa1f36e..b79030a22 100644 --- a/src/Airports/dynamicloader.cxx +++ b/src/Airports/dynamicloader.cxx @@ -123,7 +123,7 @@ void FGAirportDynamicsXMLLoader::startNode(const XMLAttributes &atts) else if (attname == "lon") lon = atts.getValue(i); else if (attname == "isOnRunway") - onRunway = (bool) std::atoi(atts.getValue(i)); + onRunway = std::atoi(atts.getValue(i)) != 0; else if (attname == "holdPointType") { string attval = atts.getValue(i); if (attval=="none") { @@ -158,7 +158,7 @@ void FGAirportDynamicsXMLLoader::startArc(const XMLAttributes &atts) else if (attname == "end") end = std::atoi(atts.getValue(i)); else if (attname == "isPushBackRoute") - isPushBackRoute = (bool) std::atoi(atts.getValue(i)); + isPushBackRoute = std::atoi(atts.getValue(i)) != 0; } _dynamics->getGroundNetwork()->addSegment(new FGTaxiSegment(begin, end, isPushBackRoute)); diff --git a/src/Canvas/elements/map/geo_node_pair.hxx b/src/Canvas/elements/map/geo_node_pair.hxx index 14a04c918..57dc7b3a4 100644 --- a/src/Canvas/elements/map/geo_node_pair.hxx +++ b/src/Canvas/elements/map/geo_node_pair.hxx @@ -42,7 +42,7 @@ namespace canvas bool isDirty() const { - return _status & DIRTY; + return (_status & DIRTY)!=0; } bool isComplete() const diff --git a/src/FDM/groundcache.cxx b/src/FDM/groundcache.cxx index 73f299ea9..0b341159a 100644 --- a/src/FDM/groundcache.cxx +++ b/src/FDM/groundcache.cxx @@ -921,7 +921,7 @@ bool FGGroundCache::caught_wire(double t, const SGVec3d pt[4]) _localBvhTree->accept(wireIntersector); _wire = wireIntersector.getWire(); - return _wire; + return (_wire != NULL); } class FGGroundCache::WireFinder : public BVHVisitor { diff --git a/src/GUI/FGColor.hxx b/src/GUI/FGColor.hxx index 3a8e4d6a9..164019df3 100644 --- a/src/GUI/FGColor.hxx +++ b/src/GUI/FGColor.hxx @@ -37,13 +37,13 @@ public: inline float red() const { return clamp(_red); } inline float green() const { return clamp(_green); } inline float blue() const { return clamp(_blue); } - inline float alpha() const { return _alpha < 0.0 ? 1.0 : clamp(_alpha); } + inline float alpha() const { return _alpha < 0.0 ? 1.0f : clamp(_alpha); } protected: float _red, _green, _blue, _alpha; private: - float clamp(float f) const { return f < 0.0 ? 0.0 : f > 1.0 ? 1.0 : f; } + float clamp(float f) const { return f < 0.0 ? 0.0f : f > 1.0 ? 1.0f : f; } }; -#endif \ No newline at end of file +#endif diff --git a/src/Input/FGDeviceConfigurationMap.cxx b/src/Input/FGDeviceConfigurationMap.cxx index 206ae6c4f..1da399fb5 100644 --- a/src/Input/FGDeviceConfigurationMap.cxx +++ b/src/Input/FGDeviceConfigurationMap.cxx @@ -77,7 +77,7 @@ FGDeviceConfigurationMap::configurationForDeviceName(const std::string& name) try { readProperties(it->second.str(), result); result->setStringValue("source", it->second.c_str()); - } catch (sg_exception& e) { + } catch (sg_exception&) { SG_LOG(SG_INPUT, SG_WARN, "parse failure reading:" << it->second); return NULL; } @@ -138,7 +138,7 @@ void FGDeviceConfigurationMap::refreshCacheForFile(const SGPath& path) SGPropertyNode_ptr n(new SGPropertyNode); try { readProperties(path.str(), n); - } catch (sg_exception& e) { + } catch (sg_exception&) { SG_LOG(SG_INPUT, SG_WARN, "parse failure reading:" << path); return; } diff --git a/src/Navaids/NavDataCache.cxx b/src/Navaids/NavDataCache.cxx index bcc82a260..d39f438a5 100644 --- a/src/Navaids/NavDataCache.cxx +++ b/src/Navaids/NavDataCache.cxx @@ -290,7 +290,7 @@ public: try { execSelect(stmt); - } catch (sg_exception& e) { + } catch (sg_exception&) { sqlite3_finalize(stmt); throw; // re-throw } @@ -596,7 +596,7 @@ public: reset(loadAirportStmt); sqlite3_bind_int64(loadAirportStmt, 1, rowId); execSelect1(loadAirportStmt); - bool hasMetar = sqlite3_column_int(loadAirportStmt, 0); + bool hasMetar = (sqlite3_column_int(loadAirportStmt, 0) > 0); return new FGAirport(rowId, id, pos, name, hasMetar, ty); } diff --git a/src/Navaids/procedure.cxx b/src/Navaids/procedure.cxx index bb53a6429..48a2846ed 100644 --- a/src/Navaids/procedure.cxx +++ b/src/Navaids/procedure.cxx @@ -152,7 +152,7 @@ bool ArrivalDeparture::isForRunway(const FGRunway* aWay) const } FGRunwayRef r(const_cast(aWay)); - return (_runways.count(r)); + return (_runways.count(r) > 0); } RunwayVec ArrivalDeparture::runways() const diff --git a/src/Network/native_ctrls.cxx b/src/Network/native_ctrls.cxx index 73c9f31ea..f468b9449 100644 --- a/src/Network/native_ctrls.cxx +++ b/src/Network/native_ctrls.cxx @@ -372,8 +372,8 @@ void FGNetCtrls2Props( FGNetCtrls *net, bool honor_freezes, // or node->setDoubleValue( "spoilers", net->spoilers ); //JWW // cout << "NET->Spoilers: " << net->spoilers << endl; - fgSetBool( "/systems/electrical/outputs/flaps", net->flaps_power ); - node->setBoolValue( "flaps-serviceable", net->flap_motor_ok ); + fgSetBool( "/systems/electrical/outputs/flaps", net->flaps_power > 0 ); + node->setBoolValue( "flaps-serviceable", net->flap_motor_ok > 0 ); for ( i = 0; i < FGNetCtrls::FG_MAX_ENGINES; ++i ) { // Controls @@ -387,27 +387,27 @@ void FGNetCtrls2Props( FGNetCtrls *net, bool honor_freezes, node->getChild( "magnetos" )->setDoubleValue( net->magnetos[i] ); node->getChild( "starter" )->setDoubleValue( net->starter_power[i] ); node->getChild( "feed_tank" )->setIntValue( net->feed_tank_to[i] ); - node->getChild( "reverser" )->setBoolValue( net->reverse[i] ); + node->getChild( "reverser" )->setBoolValue( net->reverse[i] > 0 ); // Faults SGPropertyNode *faults = node->getNode( "faults", true ); - faults->setBoolValue( "serviceable", net->engine_ok[i] ); + faults->setBoolValue( "serviceable", net->engine_ok[i] > 0 ); faults->setBoolValue( "left-magneto-serviceable", - net->mag_left_ok[i] ); + net->mag_left_ok[i] > 0 ); faults->setBoolValue( "right-magneto-serviceable", - net->mag_right_ok[i]); + net->mag_right_ok[i] > 0); faults->setBoolValue( "spark-plugs-serviceable", - net->spark_plugs_ok[i] ); + net->spark_plugs_ok[i] > 0); faults->setIntValue( "oil-pressure-status", net->oil_press_status[i] ); - faults->setBoolValue( "fuel-pump-serviceable", net->fuel_pump_ok[i] ); + faults->setBoolValue( "fuel-pump-serviceable", net->fuel_pump_ok[i] > 0); } fgSetBool( "/systems/electrical/outputs/fuel-pump", - net->fuel_pump_power[0] ); + net->fuel_pump_power[0] > 0); for ( i = 0; i < FGNetCtrls::FG_MAX_TANKS; ++i ) { node = fgGetNode( "/controls/fuel/tank", i ); node->getChild( "fuel_selector" ) - ->setBoolValue( net->fuel_selector[i] ); + ->setBoolValue( net->fuel_selector[i] > 0 ); // node->getChild( "to_tank" )->xfer_tank( i, net->xfer_to[i] ); } node = fgGetNode( "/controls/gear" ); @@ -422,15 +422,15 @@ void FGNetCtrls2Props( FGNetCtrls *net, bool honor_freezes, } node = fgGetNode( "/controls/gear", true ); - node->setBoolValue( "gear-down", net->gear_handle ); + node->setBoolValue( "gear-down", net->gear_handle > 0 ); // node->setDoubleValue( "brake-parking", net->brake_parking ); // node->setDoubleValue( net->brake_left ); // node->setDoubleValue( net->brake_right ); node = fgGetNode( "/controls/switches", true ); - node->setBoolValue( "master-bat", net->master_bat ); - node->setBoolValue( "master-alt", net->master_alt ); - node->setBoolValue( "master-avionics", net->master_avionics ); + node->setBoolValue( "master-bat", net->master_bat > 0 ); + node->setBoolValue( "master-alt", net->master_alt > 0); + node->setBoolValue( "master-avionics", net->master_avionics > 0); node = fgGetNode( "/environment", true ); node->setDoubleValue( "wind-speed-kt", net->wind_speed_kt ); @@ -456,9 +456,9 @@ void FGNetCtrls2Props( FGNetCtrls *net, bool honor_freezes, if ( honor_freezes ) { node = fgGetNode( "/sim/freeze", true ); - node->setBoolValue( "master", net->freeze & 0x01 ); - node->setBoolValue( "position", net->freeze & 0x02 ); - node->setBoolValue( "fuel", net->freeze & 0x04 ); + node->setBoolValue( "master", (net->freeze & 0x01) > 0 ); + node->setBoolValue( "position", (net->freeze & 0x02) > 0 ); + node->setBoolValue( "fuel", (net->freeze & 0x04) > 0 ); } } diff --git a/src/Network/native_gui.cxx b/src/Network/native_gui.cxx index eaae3c32a..720b08dba 100644 --- a/src/Network/native_gui.cxx +++ b/src/Network/native_gui.cxx @@ -314,7 +314,7 @@ void FGNetGUI2Props( FGNetGUI *net ) { // Approach fgSetDouble( "/instrumentation/nav[0]/frequencies/selected-mhz", net->tuned_freq ); - fgSetBool( "/instrumentation/nav[0]/in-range", net->in_range ); + fgSetBool( "/instrumentation/nav[0]/in-range", net->in_range > 0); fgSetDouble( "/instrumentation/dme/indicated-distance-nm", net->dist_nm ); fgSetDouble( "/instrumentation/nav[0]/heading-needle-deflection", net->course_deviation_deg ); diff --git a/src/Network/props.cxx b/src/Network/props.cxx index 436c2af73..5e88933d1 100644 --- a/src/Network/props.cxx +++ b/src/Network/props.cxx @@ -185,7 +185,7 @@ void PropsChannel::unsubscribe(const ParameterList ¶m) { SGPropertyNode *n = globals->get_props()->getNode( param[1].c_str() ); if (n) n->removeChangeListener( this ); - } catch (sg_exception &e) { + } catch (sg_exception&) { error("Error:Listener could not be removed"); } } diff --git a/src/Scripting/NasalPositioned.cxx b/src/Scripting/NasalPositioned.cxx index e6b56971c..3c66a4d0f 100644 --- a/src/Scripting/NasalPositioned.cxx +++ b/src/Scripting/NasalPositioned.cxx @@ -801,7 +801,7 @@ static bool hashIsCoord(naRef h) return false; } - return naEqual(naVec_get(parents, 0), geoCoordClass); + return naEqual(naVec_get(parents, 0), geoCoordClass) != 0; } bool geodFromHash(naRef ref, SGGeod& result) diff --git a/src/Scripting/nasal-props.cxx b/src/Scripting/nasal-props.cxx index 6eaa5ed30..18f5aee67 100644 --- a/src/Scripting/nasal-props.cxx +++ b/src/Scripting/nasal-props.cxx @@ -303,7 +303,7 @@ static naRef f_getChild(naContext c, naRef me, int argc, naRef* args) naRef child = naVec_get(argv, 0); if(!naIsString(child)) return naNil(); naRef idx = naNumValue(naVec_get(argv, 1)); - bool create = naTrue(naVec_get(argv, 2)); + bool create = naTrue(naVec_get(argv, 2)) != 0; SGPropertyNode* n; try { if(naIsNil(idx) || !naIsNum(idx)) { @@ -360,7 +360,7 @@ static naRef f_addChild(naContext c, naRef me, int argc, naRef* args) bool append = true; if( !naIsNil(ref_append) ) - append = naTrue(ref_append); + append = naTrue(ref_append) != 0; n = (*node)->addChild(naStr_data(child), min_index, append); } @@ -445,7 +445,7 @@ static naRef f_getNode(naContext c, naRef me, int argc, naRef* args) { NODEARG(); naRef path = naVec_get(argv, 0); - bool create = naTrue(naVec_get(argv, 1)); + bool create = naTrue(naVec_get(argv, 1)) != 0; if(!naIsString(path)) return naNil(); SGPropertyNode* n; try {