-
Notifications
You must be signed in to change notification settings - Fork 461
Resolve cppcheck unreadVariable warnings #11411
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
base: develop
Are you sure you want to change the base?
Conversation
| { | ||
|
|
||
| std::array<Real64, DataConvergParams::ConvergLogStackDepth> tmpRealARR = {}; | ||
| std::array<Real64, DataConvergParams::ConvergLogStackDepth> tmpRealARR; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove the zero-initialization of tmpRealARR. It is always overwritten before being read, so the initialization was redundant and triggered a cppcheck warning.
| } else if (field_value.get<std::string>().empty()) { | ||
| isDefaulted = findDefault(defaultValue, schema_field_obj); | ||
| if (isDefaulted) { | ||
| if (findDefault(defaultValue, schema_field_obj)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove the temporary isDefaulted variable and use findDefault() directly in the condition to remove cppcheck error as it was redundant and only stored an intermediate result.
| auto epwFile = state.files.inputWeatherFilePath.open(state, "CalcThermalComfortAdaptiveASH55"); | ||
| for (i = 1; i <= 8; ++i) { // Headers | ||
| epwLine = epwFile.readLine().data; | ||
| epwFile.readLine(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I updated the code to call readLine() without assigning the result to epwLine, since the code stored each skipped line into epwLine and immediately overwrote it in the next iteration without ever reading it. This removes the dead assignments flagged by cppcheck and makes the intent clearer, with no change in behavior. I made the same change below.
| ExpandComplexState(state, iSurf, state.dataSurface->Surface(iSurf).Construction); | ||
| CurrentCFSState = state.dataSurface->SurfaceWindow(iSurf).ComplexFen.NumStates; | ||
| state.dataSurface->SurfaceWindow(iSurf).ComplexFen.CurrentState = CurrentCFSState; | ||
| state.dataSurface->SurfaceWindow(iSurf).ComplexFen.CurrentState = state.dataSurface->SurfaceWindow(iSurf).ComplexFen.NumStates; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Drop the redundant CurrentCFSState local and write directly to ComplexFen.CurrentState. The cached value wasn’t needed and cppcheck flagged it as unreadVariable. No behavior change.
|
|
||
| ngllayer = state.dataConstruction->Construct(ConstrNum).TotGlassLayers; | ||
| nglface = 2 * ngllayer; | ||
| nglfacep = nglface; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dropped this initialization as it gets overwritten before being read, so cppcheck flags it as unreadVariable. No behavior change.
| A(3, 3) = 1.0; | ||
| A(4, 3) = -1.0 * rhodb; | ||
| A(3, 4) = -1.0 * rhom; | ||
| // cppcheck-suppress unreadVariable |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cppcheck false positive: this routine fills A as an output matrix, so the last assignment A(4,4)=1.0 isn’t unused in practice. Added a local suppress to keep the intent clear.
| } | ||
| } | ||
| } | ||
| CFSLAYERFlag = LOK && DOK && BOK; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dropped unused CFSLAYERFlag as it was computed but never read.
| TGapNew(1) = | ||
| TAve(1) - (TAve(1) - TAve(2)) * (GapHeightChar(1) / GapHeight) * (1 - EpsChar(1)) * (1 - EpsChar(2)) / (1 - EpsChar(1) * EpsChar(2)); | ||
|
|
||
| // cppcheck-suppress unreadVariable |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cppcheck false positive: TGapNew is an output array; TGapNew(2) is set here for the caller.
| Real64 BlindIRreflBack = G(2) * (1.0 - fEdge) + fEdge * ri; // Blind back IR reflectance | ||
|
|
||
| // Back IR emissivity | ||
| // cppcheck-suppress unreadVariable |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cppcheck false positive: p is an output array and p(15) is set here for the caller.
|
| int LBnd = 0; | ||
| int UBnd = NumItems + 1; | ||
| bool Found = false; | ||
| while ((!Found) || (Probe != 0)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Found is always false, so (!Found) is a redundant condition.
Pull request overview
Description of the purpose of this PR
Pull Request Author
Reviewer