[File] One more set of observations from static analysis

Steve Grubb sgrubb at redhat.com
Mon Jun 8 18:55:35 UTC 2020


Hello,

There are a couple more findings that I'd like to point out. I would send a 
patch but this appears like it was refactored code. I am unsure how to fix it, 
so I'll just point it out.

In src/ascmagic.c around lines 117 and 118, we have 2 variables: subtype & 
subtype_mime. They are both set to NULL.  At line 264, there is 

if (subtype)

which is always false because it hasn't changed since function init. I don't 
know if something higher up was supposed to set it or if this is dead code 
from a refactoring.

Similarly at line 229, we find an

if (subtype_mime)

which is always false for the same reason which means this always goes to the 
else statement. Not sure what the right fix is for either of these.

And one last item, in src/funcs.c at line 373, we find this:

if ((ms->flags & MAGIC_NO_CHECK_CSV) == 0)

which yields a message like: Predicate '==' can be pre-determined and always 
evaluates to True.

Investigating this shows that this should be fixed by an official release, but 
in the meantime something else could be wrong and we don't know it. This 
results from ./src/magic.h.in not being added to the configure.ac 
AC_CONFIG_FILES variable. Which means, my compiler and static analysis tools 
are using the system magic.h rather than the one in the master branch. 
MAGIC_NO_CHECK_CSV is not defined in 5.37 so its defined as 0 and that leads to 
the warning. I'm pretty sure you know this and I'm just mentioning it just in 
case.

Best Regards,
-Steve




More information about the File mailing list