This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Dead Code


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]