Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Doubt on rule 13.2
#2
The rule says "tests of a value against zero". As I understand it, this applies to everything that isn't Boolean: integers, pointers, float numbers, strings...

Pointers are especially troublesome, since they aren't always containing address 0, but could also contain the mysterious address NULL, which could be defined as 0 or (void*)0. Using an implicity comparison can therefore cause your compiler to whine about implicit typecasting.

It is generally considered good programming practice to explicitly compare pointers against NULL, no matter what MISRA advises regarding implicit tests against zero.
<t></t>
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 2 Guest(s)