After futher review of this function it looks like the existing
fclose() is not in the correct place, and recent patches have
added fclose() to this function in better places (covering all
returns) but did not take into account the existing misplaced
fclose().
LefHelper_DBTechNameType_LefLower() identified and introduced during
conversion to const data usage.
Only side-effect is some log messages will use original verbatim token
now instead of lowercase version (but this seems ok when file parsing,
to quote the problematic information source verbatim)
Some function parameters (char *sname) have been made const due
referencing const data sources.
K&R obsolete syntax removal for C23 compatibility series
created use of 'alloc' local variable to track when an allocation occurred
so exit path logic is more straight forward for compiler/analyser to see
potential optimisations.
the previous version was probably working just fine
created use of 'alloc' local variable to track when an allocation occurred
so exit path logic is more straight forward for compiler/analyser to see
potential optimisations.
no attempt to free memory was made previously
created use of 'alloc' local variable to track when an allocation occurred
so exit path logic is more straight forward for compiler/analyser to see
potential optimisations.
Unclear with all the flip operations if there is some kind of attachment
(exchange of channels), the other 2 channels created in the function
are also cleaned up.
Maybe it was a single bit and '!' operator inverted a single bit, but it
appears to be a 4-bit mask today.
TODO check rtrMARKED() this looks like it uses '&' operator is in use
but from the context of a bitmask maybe this should be '|' operator.
ourgl local variable is set to a non-NULL value (first initialization)
in code that is in lines below where it is dereferenced in a loop.
Somewhere in the loop there is a point where the precondition of ourgl
being set to non-null is expected.
ASSERT added.
Guided by CodeQL static code analyser.
FileMayNotBeClosed.ql
FileMayNeverBeClosed.ql
The trick with "if(fp != stdout)" is problematic (to analyser) as
technically 'stdout' can be a global pointer that COULD be modified any
time, so it might have changed between the fopen() and fclose() calls so
the close MAY NEVER occurs (which is problem the analyzer can see).
So local state is maintained as a bool which will also clarify to the
compiler see the intention without concern for external stdout
modification.
Some items appear to be out and out leaks when certain commands are use.