Re: coccinelle and bitmask arithmetic

2013-01-30 Thread Russell King - ARM Linux
On Wed, Jan 30, 2013 at 08:53:29AM -0800, Joe Perches wrote: > On Wed, 2013-01-30 at 11:35 +, Russell King - ARM Linux wrote: > > On Wed, Jan 30, 2013 at 12:21:21PM +0100, Julia Lawall wrote: > > > On Wed, 30 Jan 2013, Russell King - ARM Linux wrote: > > > > So, _either_ logical OR or addition

Re: coccinelle and bitmask arithmetic

2013-01-30 Thread Joe Perches
On Wed, 2013-01-30 at 11:35 +, Russell King - ARM Linux wrote: > On Wed, Jan 30, 2013 at 12:21:21PM +0100, Julia Lawall wrote: > > On Wed, 30 Jan 2013, Russell King - ARM Linux wrote: > > > So, _either_ logical OR or addition works. > > > > > > If we _did_ end up with a PHYS_OFFSET with bits le

Re: coccinelle and bitmask arithmetic

2013-01-30 Thread Russell King - ARM Linux
On Wed, Jan 30, 2013 at 12:21:21PM +0100, Julia Lawall wrote: > > > On Wed, 30 Jan 2013, Russell King - ARM Linux wrote: > > > On Wed, Jan 30, 2013 at 09:21:28AM +0100, walter harms wrote: > > > Great hit Joe :) > > > > > > Sometimes i am really surprised what code can be found > > > in the kern

Re: coccinelle and bitmask arithmetic

2013-01-30 Thread Julia Lawall
On Wed, 30 Jan 2013, Russell King - ARM Linux wrote: > On Wed, Jan 30, 2013 at 09:21:28AM +0100, walter harms wrote: > > Great hit Joe :) > > > > Sometimes i am really surprised what code can be found > > in the kernal and it is still working. > > Having no clue of the code i suspect somebody tr

Re: coccinelle and bitmask arithmetic

2013-01-30 Thread Russell King - ARM Linux
On Wed, Jan 30, 2013 at 09:21:28AM +0100, walter harms wrote: > Great hit Joe :) > > Sometimes i am really surprised what code can be found > in the kernal and it is still working. > Having no clue of the code i suspect somebody tries to > check is mask outside the range it should read > PHYS_OFFS

Re: coccinelle and bitmask arithmetic

2013-01-30 Thread Joe Perches
On Wed, 2013-01-30 at 09:21 +0100, walter harms wrote: > Am 29.01.2013 19:03, schrieb Joe Perches: > > On Tue, 2013-01-29 at 18:49 +0100, Julia Lawall wrote: > >> How about the following (from today's linux-next). They appear to be > >> trying to do the same calculation, once with + and once with

Re: coccinelle and bitmask arithmetic

2013-01-30 Thread walter harms
Am 29.01.2013 19:03, schrieb Joe Perches: > On Tue, 2013-01-29 at 18:49 +0100, Julia Lawall wrote: >> How about the following (from today's linux-next). They appear to be >> trying to do the same calculation, once with + and once with |. > > (cc'ing the original developer and Russell King) > >

Re: coccinelle and bitmask arithmetic (was: Re: [patch] TTY: synclink, small cleanup in dtr_rts())

2013-01-29 Thread Julia Lawall
The following rule looks promising: @r@ constant c; identifier i; expression e; @@ ( e | c@i | e & c@i | e |= c@i | e &= c@i ) @@ constant r.c,c1; identifier i1; expression e; @@ *c1@i1 + c That is, the sum of two constants where at least one of them has been used with & or |. julia -- To uns

Re: coccinelle and bitmask arithmetic (was: Re: [patch] TTY: synclink, small cleanup in dtr_rts())

2013-01-29 Thread Joe Perches
On Tue, 2013-01-29 at 18:49 +0100, Julia Lawall wrote: > How about the following (from today's linux-next). They appear to be > trying to do the same calculation, once with + and once with |. (cc'ing the original developer and Russell King) Likely the it8152_pci_platform_notify uses should use +

Re: coccinelle and bitmask arithmetic (was: Re: [patch] TTY: synclink, small cleanup in dtr_rts())

2013-01-29 Thread Julia Lawall
How about the following (from today's linux-next). They appear to be trying to do the same calculation, once with + and once with |. arch/arm/common/it8152.c int dma_set_coherent_mask(struct device *dev, u64 mask) { if (mask >= PHYS_OFFSET + SZ_64M - 1) return 0;

Re: coccinelle and bitmask arithmetic (was: Re: [patch] TTY: synclink, small cleanup in dtr_rts())

2013-01-29 Thread Dan Carpenter
Here are the warnings for yesterday's linux-next (next-20130128). regards, dan carpenter arch/x86/crypto/crc32-pclmul_glue.c:66 crc32_pclmul_le() warn: bit mask 'SCALE_F_MASK' used for math 'p + (16 - 1)' arch/x86/kernel/cpu/mcheck/mce_amd.c:155 threshold_restart_bank() warn: bit mask 'THRESHOL

Re: coccinelle and bitmask arithmetic (was: Re: [patch] TTY: synclink, small cleanup in dtr_rts())

2013-01-29 Thread Joe Perches
On Tue, 2013-01-29 at 17:19 +0100, Julia Lawall wrote: > > On Tue, 2013-01-29 at 10:55 -0500, valdis.kletni...@vt.edu wrote: [] > > > I wonder if there's a way to write a coccinelle patch to find places > > > where we do arithmetic operations on bitmasks [] > If the definition of a bitmask is a

Re: coccinelle and bitmask arithmetic (was: Re: [patch] TTY: synclink, small cleanup in dtr_rts())

2013-01-29 Thread Julia Lawall
On Tue, 29 Jan 2013, Joe Perches wrote: > On Tue, 2013-01-29 at 10:55 -0500, valdis.kletni...@vt.edu wrote: > > 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. >