Question on FAT Code

Joel Sherrill joel.sherrill at
Mon Mar 14 21:36:42 UTC 2011


Coverity (#183) reported an issue in

1081         case FAT_FAT16:
1082           /* FAT entry 0: 0xff00|media_type */
Event result_independent_of_operands: (0xff00 | fmt_params.media_code) 
 >> 8 is 0xff regardless of the values of its operands [non-specific 
operand of assignment].
1083           FAT_SET_VAL16(tmp_sec,0,0xff00|fmt_params.media_code);

Looking at the definition of FAT_SET_VAL16(),
I can see what it doesn't like.

#define FAT_SET_VAL16(x, ofs,val) do {              \
                  FAT_SET_VAL8((x),(ofs),(val));     \
                  } while (0)

In the case of line 1083, offset 1 is always 0xff.
Would this code better written as?


It avoids the evaluation to a constant for offset 1.

I know this is picky but the Coverity Scanner is correct
that offset 1 is always 0xff and we have written something
complicated to produce that.


Joel Sherrill, Ph.D.             Director of Research&  Development
joel.sherrill at        On-Line Applications Research
Ask me about RTEMS: a free RTOS  Huntsville AL 35805
    Support Available             (256) 722-9985

More information about the users mailing list