[RTEMS Project] #4863: Operations evaluation order.

RTEMS trac trac at rtems.org
Thu Feb 23 15:17:54 UTC 2023


#4863: Operations evaluation order.
---------------------------+---------------------
 Reporter:  Daniel Páscoa  |       Owner:  (none)
     Type:  defect         |      Status:  new
 Priority:  normal         |   Milestone:
Component:  admin          |     Version:  6
 Severity:  normal         |  Resolution:
 Keywords:  qualification  |  Blocked By:
 Blocking:                 |
---------------------------+---------------------

Comment (by Joel Sherrill):

 The code would be better written avoiding the use of compound expressions
 which will ease the testing when moving to higher design assurance levels
 which require MCDC style analysis. I would recommend trying to rewrite
 code to avoid compound expressions. This effectively can reduce testing to
 simpler decision/branch coverage. Here's my recommendation which also adds
 the braces which I am surprised didn't get flagged:

 {{{
   if ( !the_api ) {
     return false;
   }

   if ( the_api > OBJECTS_APIS_LAST )
     return false;
   }

   return true;
 }
 }}}

 FWIW I don't think the code as written was hard to read or confusing. I
 wouldn't have changed based solely on that report. The rules of evaluation
 in C are clear enough that anyone confused by this shouldn't be touching
 this code anyway.

--
Ticket URL: <http://devel.rtems.org/ticket/4863#comment:2>
RTEMS Project <http://www.rtems.org/>
RTEMS Project


More information about the bugs mailing list