change log for rtems (2010-07-26)

Gedare Bloom gedare at gwmail.gwu.edu
Mon Jul 26 14:50:20 UTC 2010


On Mon, Jul 26, 2010 at 10:22 AM, Sebastian Huber
<sebastian.huber at embedded-brains.de> wrote:
> On 07/26/2010 04:10 PM, rtems-vc at rtems.org wrote:
>>  *joel*
>>
>> 2010-07-26    Joel Sherrill <joel.sherrilL at OARcorp.com>
>>
>>       * rtems/src/ratemonperiod.c: Use if not switch since all cases of enum
>>       are not valid and switch was generating dead code.
>
> I don't think that the following rule is useful:
>
> enum E {
>  A,
>  B,
>  C
> };
>
> Replace
>
> switch (e) {
>  case A:
>    a();
>    return S;
>  case B;
>    b();
>    return S;
>  case C:
>    break;
> }
> return -S;
>
> with
>
> if (e == A) {
>  a();
>  return S;
> }
> if (e == B) {
>  b();
>  return S;
> }
> return -S;
>
> --
If this is solely for coverage improvement / dead code elimination,
why not just remove the 'empty' cases in the switch?  I don't know
that the new code is easier to read/understand.  High-level switch
statements on enums are pretty easy to parse.  Using if statements
might lead to dirtier code that conflates multiple cases.

-G




More information about the vc mailing list