ext2spice.c: pname used before initialization

In order for pname to be assigned a value the loop must have performed
an interation.  The order of assignment and use of 'pname' is not the
natural order you'd expect.  It also looks like the TxPrint message
may display the incorrect port name from the previous loop iteration.

The code block looks like the resolution of 'pname' has no side-effects.
So should be done first so the correct port name is output in the log message.

SonarCloud
2nd function call argument is an uninitialized value
https://sonarcloud.io/project/issues?open=AZJB17lqNGfDNup0Rk6f&id=dlmiles_magic
This commit is contained in:
Darryl L. Miles 2024-10-04 20:09:28 +01:00 committed by Tim Edwards
parent 97913ab08c
commit fcb8bf57c6
1 changed files with 9 additions and 8 deletions

View File

@ -1885,14 +1885,6 @@ topVisit(def, doStub)
else
heh = HashLookOnly(&efNodeHashTable,
(char *)snode->efnode_name->efnn_hier);
if (heh == (HashEntry *)NULL)
{
/* Port was optimized out */
snode->efnode_flags &= ~EF_PORT;
TxPrintf("Note: Port %s was optimized out of %s\n",
pname, def->def_name);
continue;
}
/* If view is abstract, rely on the given port name, not
* the node. Otherwise, artifacts of the abstract view
@ -1908,6 +1900,15 @@ topVisit(def, doStub)
// pname = nodeSpiceName(snode->efnode_name->efnn_hier, NULL);
pname = nodeSpiceName(nodeName->efnn_hier, NULL);
if (heh == (HashEntry *)NULL) /* pname now resolved for log output */
{
/* Port was optimized out */
snode->efnode_flags &= ~EF_PORT;
TxPrintf("Note: Port %s was optimized out of %s\n",
pname, def->def_name);
continue;
}
hep = HashLookOnly(&portNameTable, pname);
if (hep == (HashEntry *)NULL)
{