You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
I'm not getting this point. . . if ((!does_cross) || (newdist < tdist) is inside a for() loop. The intention is that this block is always called on the first cycle of the loop, where it sets does_cross to TRUE and initializes tdist. Throughout the rest of the loop, the "if" block is only executed if newdist < tdist. It does look like it could be simplified to just if (newdist < tdist), though.
The intention is that tmppt must be set to something before it is used. I do not know offhand what it would mean for the code to get to the abovementioned "if" block if tmppt were still uninitialized. It's worth setting a tmppt_valid if seg_intersect() returns TRUE (otherwise tmppt is meaningless) and in the two cases where tmppt is set, and then if the code attempts to set respt to tmppt then an error message can be generated, and I can go look into what happened.
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 theif ((!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.
The text was updated successfully, but these errors were encountered: