Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/ConvertInputFormat/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,6 @@ Select one (case insensitive):
#else
if (number_of_threads > 1) {
displayMessage("ConvertInputFormat is not compiled with OpenMP. Only running on 1 thread, not requested {} threads.", number_of_threads);
number_of_threads = 1;
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the non-OpenMP path, number_of_threads = 1 is assigned inside the if block but never read afterward. Removed the dead assignment.

}

for (auto const &file : files) {
Expand Down
10 changes: 5 additions & 5 deletions src/EnergyPlus/AirflowNetwork/src/Solver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5041,12 +5041,12 @@ namespace AirflowNetwork {
if (simulation_control.DuctLoss) {
// Assign node num based on Distribution node
for (int i = 1; i <= AirflowNetworkNumOfLinks; ++i) {
for (int k = 1; k <= DisSysNumOfNodes; ++k) {
if (Util::SameString(AirflowNetworkLinkageData(i).NodeNames[0], DisSysNodeData(k).Name)) {
AirflowNetworkLinkageData(i).NodeNums[0] = k;
for (int l = 1; l <= DisSysNumOfNodes; ++l) {
if (Util::SameString(AirflowNetworkLinkageData(i).NodeNames[0], DisSysNodeData(l).Name)) {
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This local k declared inside a nested block that shadows the outer function-level k. Rename the inner one to something more descriptive to avoid the shadow.

AirflowNetworkLinkageData(i).NodeNums[0] = l;
}
if (Util::SameString(AirflowNetworkLinkageData(i).NodeNames[1], DisSysNodeData(k).Name)) {
AirflowNetworkLinkageData(i).NodeNums[1] = k;
if (Util::SameString(AirflowNetworkLinkageData(i).NodeNames[1], DisSysNodeData(l).Name)) {
AirflowNetworkLinkageData(i).NodeNums[1] = l;
}
}
if (AirflowNetworkLinkageData(i).NodeNums[0] == 0) {
Expand Down
2 changes: 1 addition & 1 deletion src/EnergyPlus/BaseboardRadiator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,8 @@ namespace BaseboardRadiator {
static constexpr std::string_view availabilityScheduleFieldName = "Availability Schedule Name";
static constexpr std::string_view heatingDesignCapacityMethodFieldName = "Heating Design Capacity Method";

int ConvHWBaseboardNum = 0;
if (baseboardObjects != inputProcessor->epJSON.end()) {
int ConvHWBaseboardNum = 0;
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ConvHWBaseboardNum is declared outside the if block but only used inside the for loop. Just move the declaration inside the if block to tighten the scope. No logic change needed.

for (auto const &baseboardInstance : baseboardObjects.value().items()) {
auto const &baseboardFields = baseboardInstance.value();
auto const baseboardName = Util::makeUPPER(baseboardInstance.key());
Expand Down
2 changes: 1 addition & 1 deletion src/EnergyPlus/BoilerSteam.cc
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,8 @@ namespace BoilerSteam {
auto const &boilerSchemaProps = inputProcessor->getObjectSchemaProps(state, state.dataIPShortCut->cCurrentModuleObject);
auto const boilerObjects = inputProcessor->epJSON.find(state.dataIPShortCut->cCurrentModuleObject);

int BoilerNum = 1;
if (boilerObjects != inputProcessor->epJSON.end()) {
int BoilerNum = 1;
Copy link
Copy Markdown
Collaborator Author

@dareumnam dareumnam May 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same issue as the ConvHWBaseboardNum case. BoilerNum is declared outside the if block but only used inside the for loop within it. Just move the declaration inside the if block to tighten the scope. Easy fix, no logic change needed.

for (auto const &boilerInstance : boilerObjects.value().items()) {
auto const &boilerFields = boilerInstance.value();
auto const boilerName = Util::makeUPPER(boilerInstance.key());
Expand Down
2 changes: 1 addition & 1 deletion src/EnergyPlus/EMSManager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ namespace EMSManager {
state.dataRuntimeLang->NumExternalInterfaceFunctionalMockupUnitImportActuatorsUsed +
state.dataRuntimeLang->NumExternalInterfaceFunctionalMockupUnitExportActuatorsUsed;
++ActuatorUsedLoop) {
auto &thisActuatorUsed = state.dataRuntimeLang->EMSActuatorUsed(ActuatorUsedLoop);
auto const &thisActuatorUsed = state.dataRuntimeLang->EMSActuatorUsed(ActuatorUsedLoop);
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thisActuatorUsed is only used to read. Change it to auto const.


int ErlVariableNum = thisActuatorUsed.ErlVariableNum;
if (ErlVariableNum <= 0) {
Expand Down
2 changes: 1 addition & 1 deletion src/EnergyPlus/ElectricBaseboardRadiator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,8 @@ namespace ElectricBaseboardRadiator {
static constexpr std::string_view radiantSurfaceFractionFieldName = "Fraction of Radiant Energy to Surface";
auto const &surfaceFractionSchemaProps = elecBaseboardSchemaProps.at("surface_fractions").at("items").at("properties");

int BaseboardNum = 0;
if (elecBaseboardObjects != inputProcessor->epJSON.end()) {
int BaseboardNum = 0;
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above.

for (auto const &elecBaseboardInstance : elecBaseboardObjects.value().items()) {
auto const &elecBaseboardFields = elecBaseboardInstance.value();
auto const elecBaseboardName = Util::makeUPPER(elecBaseboardInstance.key());
Expand Down
2 changes: 1 addition & 1 deletion src/EnergyPlus/FileSystem.cc
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ namespace FileSystem {
// *
// * To resolve symlinks, wrap this call in getAbsolutePath().
// */
char executableRelativePath[1024];
char executableRelativePath[1024] = {'\0'};
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

executableRelativePath is declared but never assigned on unsupported platforms (no #else branch). So Simply fixed with initialization to avoid returning an uninitialized value.


#ifdef __APPLE__
uint32_t pathSize = sizeof(executableRelativePath);
Expand Down
1 change: 0 additions & 1 deletion src/EnergyPlus/Furnaces.cc
Original file line number Diff line number Diff line change
Expand Up @@ -706,7 +706,6 @@ namespace Furnaces {
if (errorFound) {
ShowSevereError(state, EnergyPlus::format("The index of \"{}\" is not found", thisFurnace.SuppHeatCoilName));
ShowContinueError(state, EnergyPlus::format("...occurs for {}", thisFurnace.Name));
errorFound = false;
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The last errorFound = false at the end of the suppHeatCoil error block is a dead assignment since the function returns right after and errorFound is never read again. Safe to just remove that line.

}
state.dataAirLoop->AirLoopAFNInfo(AirLoopNum).AFNLoopHeatingCoilMaxRTF =
max(refAFNLoopHeatingCoilMaxRTF, heatingCoilRTF, suppHeatingCoilRTF);
Expand Down
2 changes: 1 addition & 1 deletion src/EnergyPlus/HVACDXHeatPumpSystem.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1116,7 +1116,7 @@ namespace HVACDXHeatPumpSystem {
if (state.dataHVACDXHeatPumpSys->NumDXHeatPumpSystems > 0) {
int DXHeatSysNum = Util::FindItemInList(DXHeatCoilSysName, state.dataHVACDXHeatPumpSys->DXHeatPumpSystem);
if (DXHeatSysNum > 0 && DXHeatSysNum <= state.dataHVACDXHeatPumpSys->NumDXHeatPumpSystems) {
auto &dxhpSystem = state.dataHVACDXHeatPumpSys->DXHeatPumpSystem(DXHeatSysNum);
auto const &dxhpSystem = state.dataHVACDXHeatPumpSys->DXHeatPumpSystem(DXHeatSysNum);
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is only used to read.

NodeNum = dxhpSystem.DXHeatPumpCoilInletNodeNum;
}
}
Expand Down
24 changes: 12 additions & 12 deletions src/EnergyPlus/HVACVariableRefrigerantFlow.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7326,7 +7326,7 @@ void SetCompFlowRate(EnergyPlusData &state, int const VRFTUNum, int const VRFCon
int IndexToTUInTUList; // - index to TU in specific list for this VRF system
int TUListIndex; // index to TU list for this VRF system

auto &vrfTU = state.dataHVACVarRefFlow->VRFTU(VRFTUNum);
auto const &vrfTU = state.dataHVACVarRefFlow->VRFTU(VRFTUNum);
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is only used to read.

IndexToTUInTUList = vrfTU.IndexToTUInTUList;
TUListIndex = vrfTU.TUListIndex;

Expand Down Expand Up @@ -8272,18 +8272,18 @@ void SizeVRF(EnergyPlusData &state, int const VRFTUNum)
auto &vrfTUList = state.dataHVACVarRefFlow->TerminalUnitList(TUListNum);
for (int NumTU = 1; NumTU <= vrfTUList.NumTUInList; ++NumTU) {
int TUIndex = vrfTUList.ZoneTUPtr(NumTU);
auto &vrfTU = state.dataHVACVarRefFlow->VRFTU(TUIndex);
if (vrfTU.CoolCoilIndex > 0) {
DXCoilCap = DXCoils::GetCoilCapacityByIndexType(state, vrfTU.CoolCoilIndex, vrfTU.coolCoilType, errFlag);
auto &vrfTUobj = state.dataHVACVarRefFlow->VRFTU(TUIndex);
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

vrfTU is declared at function scope and then shadowed inside the for loop by another vrfTU pointing to a different TU. Rename the inner one to vrfTUobj to make it clear these are different objects.

if (vrfTUobj.CoolCoilIndex > 0) {
DXCoilCap = DXCoils::GetCoilCapacityByIndexType(state, vrfTUobj.CoolCoilIndex, vrfTUobj.coolCoilType, errFlag);
TUCoolingCapacity += DXCoilCap;
if (DXCoilCap == AutoSize) {
FoundAll = false;
break;
}
}

if (vrfTU.HeatCoilIndex > 0) {
DXCoilCap = DXCoils::GetCoilCapacityByIndexType(state, vrfTU.HeatCoilIndex, vrfTU.heatCoilType, errFlag);
if (vrfTUobj.HeatCoilIndex > 0) {
DXCoilCap = DXCoils::GetCoilCapacityByIndexType(state, vrfTUobj.HeatCoilIndex, vrfTUobj.heatCoilType, errFlag);
TUHeatingCapacity += DXCoilCap;
if (DXCoilCap == AutoSize) {
FoundAll = false;
Expand Down Expand Up @@ -10455,7 +10455,7 @@ int GetVRFTUOutAirNode(EnergyPlusData &state, int const VRFTUNum)
}

if (VRFTUNum > 0 && VRFTUNum <= state.dataHVACVarRefFlow->NumVRFTU) {
auto &vrfTU = state.dataHVACVarRefFlow->VRFTU(VRFTUNum);
auto const &vrfTU = state.dataHVACVarRefFlow->VRFTU(VRFTUNum);
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is only used to read.

return vrfTU.VRFTUOAMixerOANodeNum;
}
return 0;
Expand All @@ -10479,7 +10479,7 @@ int GetVRFTUZoneInletAirNode(EnergyPlusData &state, int const VRFTUNum)
}

if (VRFTUNum > 0 && VRFTUNum <= state.dataHVACVarRefFlow->NumVRFTU) {
auto &vrfTU = state.dataHVACVarRefFlow->VRFTU(VRFTUNum);
auto const &vrfTU = state.dataHVACVarRefFlow->VRFTU(VRFTUNum);
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is only used to read.

return vrfTU.VRFTUOutletNodeNum;
}
return 0;
Expand Down Expand Up @@ -10547,7 +10547,7 @@ int GetVRFTUMixedAirNode(EnergyPlusData &state, int const VRFTUNum)
}

if (VRFTUNum > 0 && VRFTUNum <= state.dataHVACVarRefFlow->NumVRFTU) {
auto &vrfTU = state.dataHVACVarRefFlow->VRFTU(VRFTUNum);
auto const &vrfTU = state.dataHVACVarRefFlow->VRFTU(VRFTUNum);
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is only used to read.

return vrfTU.VRFTUOAMixerOANodeNum;
}
return 0;
Expand All @@ -10571,7 +10571,7 @@ int GetVRFTUReturnAirNode(EnergyPlusData &state, int const VRFTUNum)
}

if (VRFTUNum > 0 && VRFTUNum <= state.dataHVACVarRefFlow->NumVRFTU) {
auto &vrfTU = state.dataHVACVarRefFlow->VRFTU(VRFTUNum);
auto const &vrfTU = state.dataHVACVarRefFlow->VRFTU(VRFTUNum);
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is only used to read.

return vrfTU.VRFTUOAMixerRetNodeNum;
}
return 0;
Expand Down Expand Up @@ -14936,7 +14936,7 @@ void VRFCondenserEquipment::VRFOU_PipeLossC(
NumIUActivated = 0;
for (int NumTU = 1; NumTU <= NumTUInList; ++NumTU) {
int TUIndex = vrfTUList.ZoneTUPtr(NumTU);
auto &vrfTU = state.dataHVACVarRefFlow->VRFTU(TUIndex);
auto const &vrfTU = state.dataHVACVarRefFlow->VRFTU(TUIndex);
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is only used to read.

int CoilIndex = vrfTU.CoolCoilIndex;

if (state.dataDXCoils->DXCoil(CoilIndex).TotalCoolingEnergyRate > 0.0) {
Expand Down Expand Up @@ -15096,7 +15096,7 @@ void VRFCondenserEquipment::VRFOU_PipeLossH(
NumIUActivated = 0;
for (int NumTU = 1; NumTU <= NumTUInList; ++NumTU) {
int TUIndex = vrfTUList.ZoneTUPtr(NumTU);
auto &vrfTU = state.dataHVACVarRefFlow->VRFTU(TUIndex);
auto const &vrfTU = state.dataHVACVarRefFlow->VRFTU(TUIndex);
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is only used to read.

int CoilIndex = vrfTU.HeatCoilIndex;

if (state.dataDXCoils->DXCoil(CoilIndex).TotalHeatingEnergyRate > 0.0) {
Expand Down
1 change: 1 addition & 0 deletions src/EnergyPlus/HeatBalanceKivaManager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@

namespace EnergyPlus::HeatBalanceKivaManager {

// cppcheck-suppress passedByValueCallback
void kivaErrorCallback(const int messageType, const std::string message, void *contextPtr)
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The message parameter in here is passed by value, but it seems intentional. The Kiva library defines the callback type as void(*)(const int, const std::string, void*) in libkiva/Errors.hpp and the signature cannot be changed on our side.

{
if (contextPtr == nullptr) {
Expand Down
6 changes: 2 additions & 4 deletions src/EnergyPlus/HeatBalanceSurfaceManager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5310,10 +5310,8 @@ void UpdateThermalHistories(EnergyPlusData &state)
SurfOutsideTempCurr * construct.CTFTUserOut[0] + state.dataHeatBalSurf->SurfTempIn(SurfNum) * construct.CTFTUserIn[0] +
state.dataHeatBalSurf->SurfQsrcHist(SurfNum, 1) * construct.CTFTUserSource[0] +
state.dataHeatBalFanSys->CTFTuserConstPart(SurfNum);
}

// Set current outside flux:
if (construct.SourceSinkPresent) {
// Set current outside flux:
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The second and third if (construct.SourceSinkPresent) checks are consecutive with no intervening changes to construct, so they can be merged into one.

state.dataHeatBalSurf->SurfOutsideFluxHist(1)(SurfNum) =
SurfOutsideTempCurr * construct.CTFOutside[0] - state.dataHeatBalSurf->SurfTempIn(SurfNum) * construct.CTFCross[0] +
state.dataHeatBalSurf->SurfQsrcHist(SurfNum, 1) * construct.CTFSourceOut[0] +
Expand Down Expand Up @@ -9936,7 +9934,7 @@ void InitSurfacePropertyViewFactors(EnergyPlusData &state)
}
if (Surface.IsSurfPropertyGndSurfacesDefined) {
GndSurfsNum = Surface.SurfPropertyGndSurfIndex;
auto &GrndSurfsProperty = state.dataSurface->GroundSurfsProperty(GndSurfsNum);
auto const &GrndSurfsProperty = state.dataSurface->GroundSurfsProperty(GndSurfsNum);
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is only used to read.

GroundSurfsViewFactor = GrndSurfsProperty.SurfsViewFactorSum;
IsGroundViewFactorSet = GrndSurfsProperty.IsGroundViewFactorSet;
SrdSurfsViewFactor += GroundSurfsViewFactor;
Expand Down
3 changes: 2 additions & 1 deletion src/EnergyPlus/IndoorGreen.cc
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,8 @@ namespace IndoorGreen {
Real64 rhoair = Psychrometrics::PsyRhoAirFnPbTdbW(state, OutPb * 1000, ZonePreTemp, ZonePreHum); // kg/m3
Real64 ETRate; // mm/s; kg/(m2s)
Real64 rs = 60 * (1500 + ZonePPFD) / (200 + ZonePPFD); // stomatal resistance s/m
Real64 ra = 350 * std::pow((0.1 / 0.1), 0.5) * (1 / (LAI + 1e-10)); // aerodynamic resistance s/m
// cppcheck-suppress duplicateExpression -- room air velocity is assumed to be 0.1 m/s & mean leaf diameter is assumed to be 0.1 m
Real64 ra = 350 * std::pow((0.1 / 0.1), 0.5) * (1 / (LAI + 1e-10)); // aerodynamic resistance s/m
ETRate = (1 / hfg) * (slopepat * (In - G) + (SwitchF * rhoair * CpAir * ZoneVPD) / ra) /
(slopepat + psyconst * (1 + rs / ra)); // Penman-Monteith ET model
return ETRate; // mm/s; kg/(m2s)
Expand Down
6 changes: 3 additions & 3 deletions src/EnergyPlus/OutputReportTabular.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13879,7 +13879,7 @@ void WriteHeatEmissionTable(EnergyPlusData &state)

if (state.dataOutRptTab->displayHeatEmissionsSummary) {

for (auto &currentStyle : ort->tabularReportPasses) {
for (auto const &currentStyle : ort->tabularReportPasses) {
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are read-only here.


if (currentStyle.produceTabular) {
WriteReportHeaders(state, "Annual Heat Emissions Report", "Entire Facility", OutputProcessor::StoreType::Average);
Expand Down Expand Up @@ -14964,7 +14964,7 @@ void ComputeLoadComponentDecayCurve(EnergyPlusData &state)
int coolDesSelected = state.dataSize->CalcFinalZoneSizing(zoneNum).CoolDDNum;
// loop over timesteps after pulse occurred
if (coolDesSelected != 0) {
auto &surfCLClDay = ort->surfCompLoads[coolDesSelected - 1];
auto const &surfCLClDay = ort->surfCompLoads[coolDesSelected - 1];
int timeOfPulse = ort->radiantPulseTimestep(coolDesSelected, zoneNum);
// if the CoolDesSelected time is on a different day than
// when the pulse occurred, need to scan back and find when
Expand Down Expand Up @@ -14992,7 +14992,7 @@ void ComputeLoadComponentDecayCurve(EnergyPlusData &state)
}
int const heatDesSelected = state.dataSize->CalcFinalZoneSizing(zoneNum).HeatDDNum;
if (heatDesSelected != 0) {
auto &surfCLHtDay = ort->surfCompLoads[heatDesSelected - 1];
auto const &surfCLHtDay = ort->surfCompLoads[heatDesSelected - 1];
int timeOfPulse = ort->radiantPulseTimestep(heatDesSelected, zoneNum);
// scan back to the day that the heating pulse occurs, if necessary
if (timeOfPulse == 0) {
Expand Down
Loading
Loading