From a7b972129639ccb375a196c7a41f184b815db006 Mon Sep 17 00:00:00 2001 From: Julian Smith Date: Thu, 11 Nov 2021 18:15:02 +0000 Subject: [PATCH] Fixed some gcc warnings. src/AIModel/AIFlightPlan.cxx: Clarify expression with extra round brackets. src/AIModel/AIFlightPlanCreate.cxx: Increased buffer size to match longest possible string. src/FDM/JSBSim/input_output/FGOutputFG.cpp: Use cast to avoid comparison of int with enum. --- src/AIModel/AIFlightPlan.cxx | 4 ++-- src/AIModel/AIFlightPlanCreate.cxx | 4 ++-- src/FDM/JSBSim/input_output/FGOutputFG.cpp | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/AIModel/AIFlightPlan.cxx b/src/AIModel/AIFlightPlan.cxx index 2eda2cacb..dcf2fdcff 100644 --- a/src/AIModel/AIFlightPlan.cxx +++ b/src/AIModel/AIFlightPlan.cxx @@ -399,8 +399,8 @@ void FGAIFlightPlan::IncrementWaypoint(bool eraseWaypoints ) int nextBearing = this->getBearing(currentWP, nextWP); nextTurnAngle = SGMiscd::normalizePeriodic(-180, 180, nextBearing - currentBearing); - if (previousWP->getSpeed()>0&&nextWP->getSpeed()<0 || - previousWP->getSpeed()<0&&nextWP->getSpeed()>0) { + if ((previousWP->getSpeed() > 0 && nextWP->getSpeed() < 0) || + (previousWP->getSpeed() < 0 && nextWP->getSpeed() > 0)) { nextTurnAngle += 180; SG_LOG(SG_AI, SG_BULK, "Add 180 to turn angle pushback end"); } diff --git a/src/AIModel/AIFlightPlanCreate.cxx b/src/AIModel/AIFlightPlanCreate.cxx index 8262d058c..415681cff 100644 --- a/src/AIModel/AIFlightPlanCreate.cxx +++ b/src/AIModel/AIFlightPlanCreate.cxx @@ -468,8 +468,8 @@ bool FGAIFlightPlan::createLandingTaxi(FGAIAircraft * ac, FGAirport * apt, // int route; for (int i = 0; i < size - 2; i++) { taxiRoute.next(node, &route); - char buffer[20]; - snprintf(buffer, 20, "landingtaxi-%d-%d", node->getIndex(), i); + char buffer[32]; + snprintf(buffer, sizeof(buffer), "landingtaxi-%d-%d", node->getIndex(), i); FGAIWaypoint *wpt = createOnGround(ac, buffer, node->geod(), apt->getElevation(), ac->getPerformance()->vTaxi()); diff --git a/src/FDM/JSBSim/input_output/FGOutputFG.cpp b/src/FDM/JSBSim/input_output/FGOutputFG.cpp index 846ea85e3..f95f980f9 100644 --- a/src/FDM/JSBSim/input_output/FGOutputFG.cpp +++ b/src/FDM/JSBSim/input_output/FGOutputFG.cpp @@ -214,7 +214,7 @@ void FGOutputFG::SocketDataFill(FGNetFDM* net) net->stall_warning = 0.0; // 0.0 - 1.0 indicating the amount of stall net->slip_deg = (float)(Auxiliary->Getbeta(inDegrees)); // slip ball deflection, deg - net->num_engines = min(FGNetFDM::FG_MAX_ENGINES,Propulsion->GetNumEngines()); // Number of valid engines + net->num_engines = min((unsigned) FGNetFDM::FG_MAX_ENGINES, Propulsion->GetNumEngines()); // Number of valid engines for (i=0; inum_engines; i++) { FGEngine* engine = Propulsion->GetEngine(i); @@ -254,7 +254,7 @@ void FGOutputFG::SocketDataFill(FGNetFDM* net) } } - net->num_tanks = min(FGNetFDM::FG_MAX_TANKS, Propulsion->GetNumTanks()); // Max number of fuel tanks + net->num_tanks = min((unsigned) FGNetFDM::FG_MAX_TANKS, Propulsion->GetNumTanks()); // Max number of fuel tanks for (i=0; inum_tanks; i++) { net->fuel_quantity[i] = (float)(((FGTank *)Propulsion->GetTank(i))->GetContents());