Off-topic: Why no compiler warning for this?

Mr. Andrei Chichak groups at chichak.ca
Wed Oct 15 21:20:33 UTC 2014


On 2014-October-15, at 2:14 AM, Peter Dufault <dufault at hda.com> wrote:

> #define ETPU_CHANNEL_BIT(CHAN) (1 << ((CHAN) % 64))
> 
> extern void foo(int chan);
> extern void bar(uint32_t bit);
> 
> void foo(int chan) {
>    uint32_t bit = ETPU_CHANNEL_BIT(chan);
>    bar(bit);
> }



I ran this bit through Gimpel lint and the only thing that it picked up is that “1” is signed and you are shifting it, should be “1U”. Trivial, but that’s what lint is good at.

It will usually pick up stuff like the potential of shifting stuff left by 64 bits, hmmmmm.

A



---------------------
Andrei Chichak

Systems Developer
CBF Systems Inc.
4-038 NINT INNOVATION CENTRE
11421 SASKATCHEWAN DRIVE
EDMONTON, ALBERTA
T6G 2M9
CANADA

Phone: 780-628-2072
Skype: andrei.chichak








-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/users/attachments/20141015/c2ef9a63/attachment-0002.html>


More information about the users mailing list