From 4ff165fdf9b740cb0a44ab3367daf640feb020f2 Mon Sep 17 00:00:00 2001 From: Michael Behrisch Date: Tue, 30 Jan 2024 22:13:46 +0100 Subject: [PATCH] fixing uninitialized variable #13596 --- src/microsim/trigger/MSChargingStation.cpp | 11 +++++------ src/microsim/trigger/MSChargingStation.h | 4 ++-- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/microsim/trigger/MSChargingStation.cpp b/src/microsim/trigger/MSChargingStation.cpp index e45324e866b..637278fe6b6 100644 --- a/src/microsim/trigger/MSChargingStation.cpp +++ b/src/microsim/trigger/MSChargingStation.cpp @@ -40,13 +40,12 @@ MSChargingStation::MSChargingStation(const std::string& chargingStationID, MSLan const std::string& name, double chargingPower, double efficency, bool chargeInTransit, SUMOTime chargeDelay, const std::string& chargeType, SUMOTime waitingTime) : MSStoppingPlace(chargingStationID, SUMO_TAG_CHARGING_STATION, std::vector(), lane, startPos, endPos, name), - myChargeInTransit(chargeInTransit), - myChargingVehicle(false) { - if (chargingPower < 0) + myChargeInTransit(chargeInTransit) { + if (chargingPower < 0) { WRITE_WARNING(TLF("Attribute % for chargingStation with ID='%' is invalid (%).", toString(SUMO_ATTR_CHARGINGPOWER), getID(), toString(chargingPower))) - else { - myChargingPower = chargingPower; - } + } else { + myChargingPower = chargingPower; + } if (efficency < 0 || efficency > 1) { WRITE_WARNING(TLF("Attribute % for chargingStation with ID='%' is invalid (%).", toString(SUMO_ATTR_EFFICIENCY), getID(), toString(efficency))) } else { diff --git a/src/microsim/trigger/MSChargingStation.h b/src/microsim/trigger/MSChargingStation.h index 6fb8fc5032b..22fc2a260f5 100644 --- a/src/microsim/trigger/MSChargingStation.h +++ b/src/microsim/trigger/MSChargingStation.h @@ -168,13 +168,13 @@ class MSChargingStation : public MSStoppingPlace { SUMOTime myWaitingTime = 0; /// @brief Check if in the current TimeStep chargingStation is charging a vehicle - bool myChargingVehicle; + bool myChargingVehicle = false; /// @brief total energy charged by this charging station double myTotalCharge = 0; /// @brief parkingArea the charging station is placed on - const MSParkingArea* myParkingArea; + const MSParkingArea* myParkingArea = nullptr; /// @brief map with the charges of this charging station (key = vehicleID) std::map > myChargeValues;