RTimothyEdwards / magic

Magic VLSI Layout Tool
Other
498 stars 103 forks source link

CFrdutils.c:917 local variable tmppt maybe read before initialization #338

Open dlmiles opened 1 month ago

dlmiles commented 1 month ago

https://github.com/RTimothyEdwards/magic/blob/master/cif/CIFrdutils.c#L917 (assignment point)

This block is always taken as does_cross==FALSE as it is assigned on function entry has not yet been changed (making the 2nd part of the if ((!does_cross) || (newdist < tdist)) redundant. So the block is always taken. Maybe there is a logic error here to consider it should be !does_cross&&newdist<tdist but there is no 'break' out of the for loop to indicate that intention.

tmppt should be assigned a safe initialized value so the assignment is not random. or maybe all assignments to populate tmppt should have a boolean flag to indicate the data is valid and populated so can be used to set does_cross=TRUE for the return value.

SonarCloud ref https://sonarcloud.io/project/issues?open=AZJB17bBNGfDNup0Rkb5&id=dlmiles_magic

This has a 23 stage static analysis what-if scenario of the events leading upto invalid data being assigned and returned.