* Dead Code
@ 2017-03-15 15:49 Joel Sherrill
2017-03-15 16:51 ` Craig Howland
0 siblings, 1 reply; 3+ messages in thread
From: Joel Sherrill @ 2017-03-15 15:49 UTC (permalink / raw)
To: newlib
Hi
I think Coverity spotted a case where an || should be an &&
in libc/string/strsignal.c. What does everyone else think?
74#if defined(SIGRTMIN) && defined(SIGRTMAX)
cond_at_most: Condition signal >= 27, taking false branch. Now the value of signal is at most 26.
at_most: At condition signal <= 31, the value of signal must be at most 26.
dead_error_condition: The condition signal <= 31 must be true.
75 if ((signal >= SIGRTMIN) || (signal <= SIGRTMAX)) {
76 siprintf (buffer, "Real-time signal %d", signal - SIGRTMIN);
77 return buffer;
78 }
79#endif
80
CID 175333 (#1 of 1): Logically dead code (DEADCODE)
dead_error_line: Execution cannot reach this statement: switch (signal) {
case 1:....
--joel
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Dead Code
2017-03-15 15:49 Dead Code Joel Sherrill
@ 2017-03-15 16:51 ` Craig Howland
2017-03-15 16:59 ` Joel Sherrill
0 siblings, 1 reply; 3+ messages in thread
From: Craig Howland @ 2017-03-15 16:51 UTC (permalink / raw)
To: newlib
On 03/15/2017 11:48 AM, Joel Sherrill wrote:
> Hi
>
> I think Coverity spotted a case where an || should be an &&
> in libc/string/strsignal.c. What does everyone else think?
>
> 74#if defined(SIGRTMIN) && defined(SIGRTMAX)
> cond_at_most: Condition signal >= 27, taking false branch. Now the
> value of signal is at most 26.
> at_most: At condition signal <= 31, the value of signal must be at most
> 26.
> dead_error_condition: The condition signal <= 31 must be true.
> 75 if ((signal >= SIGRTMIN) || (signal <= SIGRTMAX)) {
> 76 siprintf (buffer, "Real-time signal %d", signal - SIGRTMIN);
> 77 return buffer;
> 78 }
> 79#endif
> 80
>
> CID 175333 (#1 of 1): Logically dead code (DEADCODE)
> dead_error_line: Execution cannot reach this statement: switch (signal) {
>
> case 1:....
>
> --joel
I agree. (Very easy to test, for that matter.)
Craig
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Dead Code
2017-03-15 16:51 ` Craig Howland
@ 2017-03-15 16:59 ` Joel Sherrill
0 siblings, 0 replies; 3+ messages in thread
From: Joel Sherrill @ 2017-03-15 16:59 UTC (permalink / raw)
To: Craig Howland, newlib
On 3/15/2017 11:51 AM, Craig Howland wrote:
> On 03/15/2017 11:48 AM, Joel Sherrill wrote:
>> Hi
>>
>> I think Coverity spotted a case where an || should be an &&
>> in libc/string/strsignal.c. What does everyone else think?
>>
>> 74#if defined(SIGRTMIN) && defined(SIGRTMAX)
>> cond_at_most: Condition signal >= 27, taking false branch. Now the
>> value of signal is at most 26.
>> at_most: At condition signal <= 31, the value of signal must be at most
>> 26.
>> dead_error_condition: The condition signal <= 31 must be true.
>> 75 if ((signal >= SIGRTMIN) || (signal <= SIGRTMAX)) {
>> 76 siprintf (buffer, "Real-time signal %d", signal - SIGRTMIN);
>> 77 return buffer;
>> 78 }
>> 79#endif
>> 80
>>
>> CID 175333 (#1 of 1): Logically dead code (DEADCODE)
>> dead_error_line: Execution cannot reach this statement: switch (signal) {
>>
>> case 1:....
>>
>> --joel
> I agree. (Very easy to test, for that matter.)
I was thinking the same thing about a test and was
writing one while waiting for some feedback. Based
on this output, it is definitely broken!!
=== Normal Signals
signal=SIGHUP => Real-time signal -26
signal=SIGINT => Real-time signal -25
signal=SIGQUIT => Real-time signal -24
signal=SIGILL => Real-time signal -23
It also looks like I wrote this code so I should
take my lashings with a wet noodle. :)
Patch coming shortly.
Thanks for the review. I hope you will join in
and take a look at some of them.
--joel
> Craig
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-03-15 16:59 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-15 15:49 Dead Code Joel Sherrill
2017-03-15 16:51 ` Craig Howland
2017-03-15 16:59 ` Joel Sherrill
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).