Re: [patch] TTY: synclink, small cleanup in dtr_rts()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, 27 Jan 2013 23:19:47 +0300, Dan Carpenter said:

> Yeah.  I think it would be, but adding bitflags together instead of
> doing bitwise ORs is very common as well.

The fact it's common doesn't mean it's good programming practice,
or even correct.  Consider:

#define F_FOO 0x01
#define F_BAR 0x02
#define F_BAZ 0x04

unsigned int flags = F_FOO;
...
      flags |= F_BAR;

Now some time later, another code path does this:

      flags += F_FOO;

If it was another |, it would be a no harm no foul class of bug.
But how long is it going to take you to figure out who set F_BAZ?

I wonder if there's a way to write a coccinelle patch to find places
where we do arithmetic operations on bitmasks....

Attachment: pgppEVmEB3rTR.pgp
Description: PGP signature


[Index of Archives]     [Kernel Development]     [Kernel Announce]     [Kernel Newbies]     [Linux Networking Development]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Device Mapper]

  Powered by Linux