Skip to content

Commit

Permalink
Explicitly initialize two local variables to 0 (sonic-net#3046)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
saiarcot895 authored Feb 14, 2024
1 parent b3b6a83 commit 1221eae
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion orchagent/orch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,7 @@ set<string> Orch::generateIdListFromMap(unsigned long idsMap, sai_uint32_t maxId
{
unsigned long currentIdMask = 1;
bool started = false, needGenerateMap = false;
sai_uint32_t lower, upper;
sai_uint32_t lower = 0, upper = 0;
set<string> idStringList;
for (sai_uint32_t id = 0; id <= maxId; id ++)
{
Expand Down

0 comments on commit 1221eae

Please sign in to comment.