]> git.mxchange.org Git - flightgear.git/commitdiff
Fix some compiler warnings.
authorThorstenB <brehmt@gmail.com>
Sat, 13 Oct 2012 15:59:47 +0000 (17:59 +0200)
committerThorstenB <brehmt@gmail.com>
Sat, 13 Oct 2012 15:59:47 +0000 (17:59 +0200)
Unused vars, loss of precision, bool type conversions.

12 files changed:
src/Airports/dynamicloader.cxx
src/Canvas/elements/map/geo_node_pair.hxx
src/FDM/groundcache.cxx
src/GUI/FGColor.hxx
src/Input/FGDeviceConfigurationMap.cxx
src/Navaids/NavDataCache.cxx
src/Navaids/procedure.cxx
src/Network/native_ctrls.cxx
src/Network/native_gui.cxx
src/Network/props.cxx
src/Scripting/NasalPositioned.cxx
src/Scripting/nasal-props.cxx

index 79fa1f36eecc484a2d6f73da29800a61d6f1c370..b79030a22be3d6d3480dccbe4db8e7257e0ea76e 100644 (file)
@@ -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));
index 14a04c918336749d02d19c1d18399376cae520d0..57dc7b3a448a10becb463bf7278d009d23510062 100644 (file)
@@ -42,7 +42,7 @@ namespace canvas
 
       bool isDirty() const
       {
-        return _status & DIRTY;
+        return (_status & DIRTY)!=0;
       }
 
       bool isComplete() const
index 73f299ea98975b74fca9a26f8108e0fea8d837ee..0b341159aadd04bae91e51e22971dc989d2fd461 100644 (file)
@@ -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 {
index 3a8e4d6a9022379bb3f89a481061cf3c0b903cd8..164019df3eb56d9281ae987610659ba39fbbbf13 100644 (file)
@@ -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
index 206ae6c4f42b61466669f46fd5b08737155ebef9..1da399fb5ae5db9dfe38d68fc157cee009b3f69a 100644 (file)
@@ -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;
   }
index bcc82a2609c7e7a44a62599ec2707f8fa79a00a9..d39f438a5d67b57e6d75174f06460138152f8f5a 100644 (file)
@@ -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);
   }
   
index bb53a642929c8852d96f92ae861d1b4c268708d5..48a2846ed85fc065086076cbc50c460c17536ce6 100644 (file)
@@ -152,7 +152,7 @@ bool ArrivalDeparture::isForRunway(const FGRunway* aWay) const
   }
   
   FGRunwayRef r(const_cast<FGRunway*>(aWay));
-  return (_runways.count(r));
+  return (_runways.count(r) > 0);
 }
 
 RunwayVec ArrivalDeparture::runways() const
index 73c9f31ea73815b0ee23d857f727ae769716e7d8..f468b9449ec8caf5c76adb52d80deca2b7b50d93 100644 (file)
@@ -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 );
     }
 }
 
index eaae3c32a0adbabb07b8242d5621b88d46f7616a..720b08dba6c9167717c41578b6ce47e92cffd0a5 100644 (file)
@@ -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 );
index 436c2af73eb0adee77233262a75e2f276fb8ea9e..5e88933d18e2e541a2bee356f0171c88ae7f1b55 100644 (file)
@@ -185,7 +185,7 @@ void PropsChannel::unsubscribe(const ParameterList &param) {
    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");
   }
 }
index e6b56971ced6828d75bc1897c47db0590ccb9428..3c66a4d0f30b042fd390e8cb3467c1b6f5831f34 100644 (file)
@@ -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)
index 6eaa5ed3010be88b8596cb27728ffb6c2bf97daa..18f5aee678b6ff286156b61209e82e6db8462cbe 100644 (file)
@@ -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 {