Re: shame on MISRA
- From: Arlet <usenet+5@xxxxxxxxxx>
- Date: 22 Apr 2007 08:58:18 -0700
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
rid of complaints in two ways:
- write 0xFFFFFFFFU instead of -1U (how many Fs do you see? 8? 7? 9? If someone
removes one F will you be able to spot it easily? IMHO- no, you will not.
Even, if you have it #defined),
- add a signed variable, initialise it with -1U, and convert it explicitly to
unsigned in expression (superfluous variable does not add to visibility).
Now, both ways are clumsy, hard to read and look like a dirty hack IMHO.
What would you say?
Just use ~0U
.
- Follow-Ups:
- Re: shame on MISRA
- From: Marcin Wolcendorf
- Re: shame on MISRA
- References:
- Re: shame on MISRA
- From: Marcin Wolcendorf
- Re: shame on MISRA
- Prev by Date: Re: CANbus consultant?
- Next by Date: Re: If ever there is need for MISRA C then this is it!
- Previous by thread: Re: shame on MISRA
- Next by thread: Re: shame on MISRA
- Index(es):
Relevant Pages
|