bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#15634: coreutils-8.21 possible coding error ?


From: Paul Eggert
Subject: bug#15634: coreutils-8.21 possible coding error ?
Date: Thu, 17 Oct 2013 07:09:48 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.0

David Binderman wrote:

> [lib/sig2str.c:329]: (warning) Logical conjunction always evaluates to false: 
> signum <= -1 && signum>= 0.

This seems to be cppcheck complaining about a test that is needed
on other platforms, but which the compiler can optimize away on
your platform.  We can safely ignore this diagnostic as well:
it's perfectly OK, and in fact nice, to have code that a compiler
can optimize away on some platforms.

>   if (!print_database < argc)
> 
> Some round brackets might help clarify the code
> 
>   if ((!print_database) < argc)

The code's pretty clear as-is, since there
are spaces around the " < " but not after the "!".

I think I'd rather ignore this diagnostic; in general,
"Comparison of a boolean value using relational operator (<,>, <= or>=)"
is bogus.  There's nothing wrong with comparing Booleans.
If you have two Booleans A and B, and want to write "A implies B",
it's often faster and (once you get used to it) more comprehensible
to write "A <= B", instead of the "!A | B" that cppcheck would
seem to require.  (Admittedly I'd rather write "A -> B"
but this is C we're talking about....)

Eric already covered the other two diagnostics you mentioned.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]