Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CppCheck FluidProperties through HVACUnitaryBypassVAV #10668

Merged
merged 3 commits into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
92 changes: 35 additions & 57 deletions src/EnergyPlus/FluidProperties.cc

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/EnergyPlus/FluidProperties.hh
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@ namespace FluidProperties {
int UpperBound // Valid values upper bound (set by calling program)
);

bool CheckFluidPropertyName(EnergyPlusData &state,
bool CheckFluidPropertyName(EnergyPlusData const &state,
std::string const &NameToCheck); // Name from input(?) to be checked against valid FluidPropertyNames

void ReportOrphanFluids(EnergyPlusData &state);
Expand Down
8 changes: 1 addition & 7 deletions src/EnergyPlus/Furnaces.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2768,8 +2768,6 @@ namespace Furnaces {
// Get fan data
FanName = Alphas(7);

errFlag = false;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

[src/EnergyPlus/Furnaces.cc:2793]:(style),[redundantAssignment],Variable 'errFlag' is reassigned a value before the old one has been used.

thisFurnace.fanType = static_cast<HVAC::FanType>(getEnumValue(HVAC::fanTypeNamesUC, Alphas(6)));

if (thisFurnace.fanType == HVAC::FanType::OnOff || thisFurnace.fanType == HVAC::FanType::Constant) {
Expand Down Expand Up @@ -4739,11 +4737,7 @@ namespace Furnaces {

if (!state.dataGlobal->DoingSizing && state.dataFurnaces->MySecondOneTimeFlag(FurnaceNum)) {
// sizing all done. check fan air flow rates
errFlag = false;
thisFurnace.ActualFanVolFlowRate = state.dataFans->fans(thisFurnace.FanIndex)->maxAirFlowRate;
if (errFlag) {
ShowContinueError(state, format("...occurs in {} ={}", HVAC::unitarySysTypeNames[(int)thisFurnace.type], thisFurnace.Name));
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

[src/EnergyPlus/Furnaces.cc:4744]:(style),[knownConditionTrueFalse],Condition 'errFlag' is always false

if (thisFurnace.ActualFanVolFlowRate != DataSizing::AutoSize) {
if (thisFurnace.DesignFanVolFlowRate > thisFurnace.ActualFanVolFlowRate) {
ShowWarningError(state,
Expand Down Expand Up @@ -5001,11 +4995,11 @@ namespace Furnaces {
thisFurnace.CoolingSpeedRatio = thisFurnace.MaxCoolAirVolFlow / thisFurnace.ActualFanVolFlowRate;
thisFurnace.NoHeatCoolSpeedRatio = thisFurnace.MaxNoCoolHeatAirVolFlow / thisFurnace.ActualFanVolFlowRate;
}
std::string FanName; // used in warning messages
if (dynamic_cast<Fans::FanComponent *>(state.dataFans->fans(thisFurnace.FanIndex))->powerRatioAtSpeedRatioCurveNum > 0) {
if (thisFurnace.ActualFanVolFlowRate == thisFurnace.MaxHeatAirVolFlow &&
thisFurnace.ActualFanVolFlowRate == thisFurnace.MaxCoolAirVolFlow &&
thisFurnace.ActualFanVolFlowRate == thisFurnace.MaxNoCoolHeatAirVolFlow) {
std::string FanName = state.dataFans->fans(thisFurnace.FanIndex)->Name;
ShowWarningError(state, format("{} \"{}\"", HVAC::unitarySysTypeNames[(int)thisFurnace.type], thisFurnace.Name));
ShowContinueError(state,
format("...For fan type and name = {} \"{}\"", HVAC::fanTypeNames[(int)thisFurnace.fanType], FanName));
Expand Down
2 changes: 1 addition & 1 deletion src/EnergyPlus/HVACInterfaceManager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ void UpdateHVACInterface(EnergyPlusData &state,
Real64 totDemandSideMaxAvail = 0.0;
for (int demIn = 1; demIn <= state.dataAirLoop->AirToZoneNodeInfo(AirLoopNum).NumSupplyNodes; ++demIn) {
int demInNode = state.dataAirLoop->AirToZoneNodeInfo(AirLoopNum).ZoneEquipSupplyNodeNum(demIn);
auto &node = state.dataLoopNodes->Node(demInNode);
auto const &node = state.dataLoopNodes->Node(demInNode);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

[src/EnergyPlus/HVACInterfaceManager.cc:126]:(style),[constVariable],Variable 'node' can be declared as reference to const

totDemandSideMassFlow += node.MassFlowRate;
totDemandSideMinAvail += node.MassFlowRateMinAvail;
totDemandSideMaxAvail += node.MassFlowRateMaxAvail;
Expand Down
2 changes: 1 addition & 1 deletion src/EnergyPlus/HVACManager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2051,7 +2051,7 @@ void ResolveLockoutFlags(EnergyPlusData &state, bool &SimAir) // TRUE means air
}
}

void ResetHVACControl(EnergyPlusData &state)
void ResetHVACControl(EnergyPlusData const &state)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

[src/EnergyPlus/HVACManager.cc:2054]:(style),[constParameter],Parameter 'state' can be declared as reference to const

{

// SUBROUTINE INFORMATION:
Expand Down
2 changes: 1 addition & 1 deletion src/EnergyPlus/HVACManager.hh
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ namespace HVACManager {

void ResolveLockoutFlags(EnergyPlusData &state, bool &SimAir); // TRUE means air loops must be (re)simulated

void ResetHVACControl(EnergyPlusData &state);
void ResetHVACControl(EnergyPlusData const &state);

void ResetNodeData(EnergyPlusData &state);

Expand Down
5 changes: 1 addition & 4 deletions src/EnergyPlus/HVACStandAloneERV.cc
Original file line number Diff line number Diff line change
Expand Up @@ -275,14 +275,13 @@ void GetStandAloneERV(EnergyPlusData &state)
ShowContinueError(state, format("... occurs in {} \"{}\"", CurrentModuleObject, standAloneERV.Name));
ErrorsFound = true;
}

standAloneERV.DesignHXVolFlowRate = HXSupAirFlowRate;

standAloneERV.SupplyAirFanName = Alphas(4);
GlobalNames::IntraObjUniquenessCheck(
state, Alphas(4), CurrentModuleObject, cAlphaFields(4), state.dataHVACStandAloneERV->SupplyAirFanUniqueNames, ErrorsFound);

errFlag = false;

if ((standAloneERV.SupplyAirFanIndex = Fans::GetFanIndex(state, standAloneERV.SupplyAirFanName)) == 0) {
ShowSevereItemNotFound(state, eoh, cAlphaFields(4), standAloneERV.SupplyAirFanName);
ErrorsFound = true;
Expand All @@ -297,7 +296,6 @@ void GetStandAloneERV(EnergyPlusData &state)
standAloneERV.ExhaustAirFanName = Alphas(5);
GlobalNames::IntraObjUniquenessCheck(
state, Alphas(5), CurrentModuleObject, cAlphaFields(5), state.dataHVACStandAloneERV->ExhaustAirFanUniqueNames, ErrorsFound);
errFlag = false;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

[src/EnergyPlus/HVACStandAloneERV.cc:300]:(style),[redundantAssignment],Variable 'errFlag' is reassigned a value before the old one has been used.


if ((standAloneERV.ExhaustAirFanIndex = Fans::GetFanIndex(state, standAloneERV.ExhaustAirFanName)) == 0) {
ShowSevereItemNotFound(state, eoh, cAlphaFields(5), standAloneERV.ExhaustAirFanName);
Expand Down Expand Up @@ -1695,7 +1693,6 @@ int getEqIndex(EnergyPlusData &state, std::string_view CompName)
for (int StandAloneERVNum = 1; StandAloneERVNum <= state.dataHVACStandAloneERV->NumStandAloneERVs; StandAloneERVNum++) {
if (Util::SameString(CompName, state.dataHVACStandAloneERV->StandAloneERV(StandAloneERVNum).Name)) {
return StandAloneERVNum;
break;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

[src/EnergyPlus/HVACStandAloneERV.cc:1698]:(style),[duplicateBreak],Consecutive return, break, continue, goto or throw statements are unnecessary.

}
}
return 0;
Expand Down
7 changes: 3 additions & 4 deletions src/EnergyPlus/HVACUnitaryBypassVAV.cc
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,6 @@ namespace HVACUnitaryBypassVAV {
bool ErrorsFound(false); // Set to true if errors in input, fatal at end of routine
bool DXErrorsFound(false); // Set to true if errors in get coil input
Array1D_int OANodeNums(4); // Node numbers of OA mixer (OA, EA, RA, MA)
std::string HXDXCoolCoilName; // Name of DX cooling coil used with Heat Exchanger Assisted Cooling Coil
Copy link
Contributor Author

Choose a reason for hiding this comment

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

[src/EnergyPlus/HVACUnitaryBypassVAV.cc:333]:(style),[unusedVariable],Unused variable: HXDXCoolCoilName

bool DXCoilErrFlag; // used in warning messages

Array1D_string Alphas(20, "");
Expand Down Expand Up @@ -754,7 +753,7 @@ namespace HVACUnitaryBypassVAV {
ShowContinueError(state, format("...occurs in {} \"{}\"", thisCBVAV.UnitType, thisCBVAV.Name));
ErrorsFound = true;
} else {
auto &newCoil = state.dataCoilCooingDX->coilCoolingDXs[thisCBVAV.DXCoolCoilIndexNum];
auto const &newCoil = state.dataCoilCooingDX->coilCoolingDXs[thisCBVAV.DXCoolCoilIndexNum];
Copy link
Contributor Author

Choose a reason for hiding this comment

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

[src/EnergyPlus/HVACUnitaryBypassVAV.cc:757]:(style),[constVariable],Variable 'newCoil' can be declared as reference to const

thisCBVAV.DXCoilInletNode = newCoil.evapInletNodeIndex;
thisCBVAV.DXCoilOutletNode = newCoil.evapOutletNodeIndex;
thisCBVAV.CondenserNodeNum = newCoil.condInletNodeIndex;
Expand Down Expand Up @@ -2444,7 +2443,7 @@ namespace HVACUnitaryBypassVAV {
}
// now find the speed ratio for the found speednum
auto f = [&state, CBVAVNum, SpeedNum, DesOutTemp](Real64 const SpeedRatio) {
auto &thisCBVAV = state.dataHVACUnitaryBypassVAV->CBVAV(CBVAVNum);
auto const &thisCBVAV = state.dataHVACUnitaryBypassVAV->CBVAV(CBVAVNum);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

[src/EnergyPlus/HVACUnitaryBypassVAV.cc:2447]:(style),[constVariable],Variable 'thisCBVAV' can be declared as reference to const

// FUNCTION LOCAL VARIABLE DECLARATIONS:
Real64 OutletAirTemp; // outlet air temperature [C]
Real64 QZnReqCycling = 0.001;
Expand Down Expand Up @@ -3429,7 +3428,7 @@ namespace HVACUnitaryBypassVAV {

// SUBROUTINE LOCAL VARIABLE DECLARATIONS:
Real64 ZoneLoad = 0.0; // Total load in controlled zone [W]
int lastDayOfSim(0); // used during warmup to reset changeOverTimer since need to do same thing next warmup day
int lastDayOfSim(0); // used during warmup to reset changeOverTimer since need to do same thing next warmup day

auto &cBVAV = state.dataHVACUnitaryBypassVAV->CBVAV(CBVAVNum);

Expand Down
Loading