Re: shame on MISRA



On Apr 23, 5:46 am, Marcin Wolcendorf <wolce...@xxxxxxxxxxxxxx> wrote:
Marcin Wolcendorf <wolce...@xxxxxxxxxxxxxx> wrote:
On Sun, 22 Apr 2007 08:58:18 -0700, Arlet wrote:

On Apr 22, 12:44 pm, Marcin Wolcendorf <wolce...@xxxxxxxxxxxxxx>
wrote:

No. It doesn't. One of the rules states (I don't have them in front
of me), that you can't use signed constants (like -1U) to set
unsigned variables. -1U is a nice value of all 1s binary,
convenient for masking. Well, you can get
...

Just use ~0U

True :).
I can't recall the reason, why I didn't use it.

Yeah, now I can. It just doesn't matter. If I use ~0U it will trigger
MISRA-C rule 10.1 (An integer constant expression with negative value is

Maybe I'm being exceptionally dense this morning but What integer
constant expression with a negative value?

being converted to an unsigned type.) just as -1U does. No difference
from MISRA-C check point of view. It is a better way- logical operators
only, and this is a logical value- but it is not enough.

Is this an automated check against the rules or a hand check?

Robert

.



Relevant Pages

  • Re: shame on MISRA
    ... I can't recall the reason, ... MISRA-C rule 10.1 (An integer constant expression with negative value is ... I still don't see an integer constant expression with a negative value. ...
    (comp.arch.embedded)
  • Re: shame on MISRA
    ... MISRA-C rule 10.1 (An integer constant expression with negative value is ... enough to trigger the rule. ... It is a better way- logical operators ...
    (comp.arch.embedded)
  • Re: shame on MISRA
    ... constant expression with a negative value? ... when the underlying code doesn't in fact depend on having an unsigned 16 ...
    (comp.arch.embedded)
  • Re: shame on MISRA
    ... It just doesn't matter. ... constant expression with a negative value? ...
    (comp.arch.embedded)
  • Re: EXIT_SUCCESS guaranteed to always be zero?
    ... > To imply that EXIT_SUCCESS (integer constant expression ... constant expression, but the value of that expression is undefined. ... at least some versions of VMS C defined EXIT_SUCCESS ... not to use numeric arguments to exit() other than 0. ...
    (comp.lang.c)