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

Explicitly initialize two local variables to 0 #3046

Merged
merged 1 commit into from
Feb 14, 2024

Conversation

saiarcot895
Copy link
Contributor

@saiarcot895 saiarcot895 commented Feb 12, 2024

What I did

GCC 12 (in Debian Bookworm) claims that on armhf targets, the lower local variable in Orch::generateIdListFromMap could potentially be used uninitialized a few lines later when it's being converted to a string. I don't see how that could be the case here, since if the string is being printed, the only code path where this is possible requires lower to have been set to something. It also only complains about this for armhf and i386 (i.e. 32-bit platforms); amd64 and arm64 (64-bit platforms) are fine. (i386 was manually tested by installing the 32-bit crosscompiler and development headers in a slave container and running the g++ command to compile orch.cpp.)

Why I did it

To silence the warning, set both lower and upper to 0 explicitly.

How I verified it

Details if related

GCC 12 (in Debian Bookworm) claims that on armhf targets, the `lower`
local variable in `Orch::generateIdListFromMap` could potentially be
used uninitialized a few lines later when it's being converted to a
string. I don't see how that could be the case here, since if the string
is being printed, the only code path where this is possible requires
`lower` to have been set to something.

To silence the warning, set both `lower` and `upper` to 0 explicitly.

Signed-off-by: Saikrishna Arcot <[email protected]>
@prsunny prsunny merged commit 1221eae into sonic-net:master Feb 14, 2024
14 checks passed
@saiarcot895 saiarcot895 deleted the fix-bookworm-armhf-build branch February 14, 2024 01:50
cscarpitta pushed a commit to cscarpitta/sonic-swss that referenced this pull request Apr 5, 2024
GCC 12 (in Debian Bookworm) claims that on armhf targets, the `lower`
local variable in `Orch::generateIdListFromMap` could potentially be
used uninitialized a few lines later when it's being converted to a
string. I don't see how that could be the case here, since if the string
is being printed, the only code path where this is possible requires
`lower` to have been set to something.

To silence the warning, set both `lower` and `upper` to 0 explicitly.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants