LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* Re: + bluetooth-fix-warning-in-net-bluetooth-hci_sysfsc.patch added to -mm tree
       [not found] <200802160449.m1G4nX5V009024@imap1.linux-foundation.org>
@ 2008-02-16  9:27 ` David Miller
  2008-02-16  9:54   ` Andrew Morton
  0 siblings, 1 reply; 3+ messages in thread
From: David Miller @ 2008-02-16  9:27 UTC (permalink / raw)
  To: linux-kernel, akpm; +Cc: hidave.darkstar

From: akpm@linux-foundation.org
Date: Fri, 15 Feb 2008 20:49:33 -0800

> Subject: bluetooth: fix warning in net/bluetooth/hci_sysfs.c
> From: Andrew Morton <akpm@linux-foundation.org>
> 
> net/bluetooth/hci_sysfs.c: In function 'del_conn':
> net/bluetooth/hci_sysfs.c:339: warning: suggest parentheses around assignment used as truth value
> 
> Cc: Dave Young <hidave.darkstar@gmail.com>
> Cc: David S. Miller <davem@davemloft.net>
> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

Linus barfed when this exact patch got posted a few weeks
ago, he said he considers just adding parenthesis to quiet
this warning awful and explicit NULL test should be used.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: + bluetooth-fix-warning-in-net-bluetooth-hci_sysfsc.patch added to -mm tree
  2008-02-16  9:27 ` + bluetooth-fix-warning-in-net-bluetooth-hci_sysfsc.patch added to -mm tree David Miller
@ 2008-02-16  9:54   ` Andrew Morton
  2008-02-16 12:03     ` Roel Kluin
  0 siblings, 1 reply; 3+ messages in thread
From: Andrew Morton @ 2008-02-16  9:54 UTC (permalink / raw)
  To: David Miller; +Cc: linux-kernel, hidave.darkstar

On Sat, 16 Feb 2008 01:27:41 -0800 (PST) David Miller <davem@davemloft.net> wrote:

> From: akpm@linux-foundation.org
> Date: Fri, 15 Feb 2008 20:49:33 -0800
> 
> > Subject: bluetooth: fix warning in net/bluetooth/hci_sysfs.c
> > From: Andrew Morton <akpm@linux-foundation.org>
> > 
> > net/bluetooth/hci_sysfs.c: In function 'del_conn':
> > net/bluetooth/hci_sysfs.c:339: warning: suggest parentheses around assignment used as truth value
> > 
> > Cc: Dave Young <hidave.darkstar@gmail.com>
> > Cc: David S. Miller <davem@davemloft.net>
> > Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
> 
> Linus barfed when this exact patch got posted a few weeks
> ago, he said he considers just adding parenthesis to quiet
> this warning awful and explicit NULL test should be used.

-	while (dev = device_find_child(&conn->dev, NULL, __match_tty)) {
+	while ((dev = device_find_child(&conn->dev, NULL, __match_tty))) {

hrm.

box:/usr/src/linux-2.6.25-rc2> grep -r 'while [(][(].*{$' . | wc -l               
1240
box:/usr/src/linux-2.6.25-rc2> grep -r 'while [(][(].*{$' . | grep -v NULL | wc -l
867

so two thirds of them presently don't bother testing for NULL.  It's a
pretty common idiom.

(adds the != NULL, sees that it reaches column 82, drops patch in disgust)

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: + bluetooth-fix-warning-in-net-bluetooth-hci_sysfsc.patch added to -mm tree
  2008-02-16  9:54   ` Andrew Morton
@ 2008-02-16 12:03     ` Roel Kluin
  0 siblings, 0 replies; 3+ messages in thread
From: Roel Kluin @ 2008-02-16 12:03 UTC (permalink / raw)
  To: Andrew Morton; +Cc: David Miller, linux-kernel, hidave.darkstar

Andrew Morton wrote:
> On Sat, 16 Feb 2008 01:27:41 -0800 (PST) David Miller <davem@davemloft.net> wrote:
> 
>> From: akpm@linux-foundation.org
>> Date: Fri, 15 Feb 2008 20:49:33 -0800
>>
>>> Subject: bluetooth: fix warning in net/bluetooth/hci_sysfs.c
>>> From: Andrew Morton <akpm@linux-foundation.org>
>>>
>>> net/bluetooth/hci_sysfs.c: In function 'del_conn':
>>> net/bluetooth/hci_sysfs.c:339: warning: suggest parentheses around assignment used as truth value
>>>
>>> Cc: Dave Young <hidave.darkstar@gmail.com>
>>> Cc: David S. Miller <davem@davemloft.net>
>>> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
>> Linus barfed when this exact patch got posted a few weeks
>> ago, he said he considers just adding parenthesis to quiet
>> this warning awful and explicit NULL test should be used.
> 
> -	while (dev = device_find_child(&conn->dev, NULL, __match_tty)) {
> +	while ((dev = device_find_child(&conn->dev, NULL, __match_tty))) {
> 
> hrm.
> 
> box:/usr/src/linux-2.6.25-rc2> grep -r 'while [(][(].*{$' . | wc -l               
> 1240
> box:/usr/src/linux-2.6.25-rc2> grep -r 'while [(][(].*{$' . | grep -v NULL | wc -l
> 867
> 
> so two thirds of them presently don't bother testing for NULL.  It's a
> pretty common idiom.
> 
> (adds the != NULL, sees that it reaches column 82, drops patch in disgust)

Not my results:

# greps for 'while ((x = y(...)))' see below for variables

git-grep -n -A2 "while" | 
sed -n "s/^\([^\.]*\.[chsS]-[0-9]*-\|\([^\.]*\.[chsS]:[0-9]*:\)$s\)\(.*\)$/\2\3/p" |
tr "\n" "@" |
grep -o "@[^@]*while$z($z($z$W$z=$z$W$z($h)$z)$z)" |
tr "@\t" " " | tr -s " " | wc -l
262

# while ((x = y(...)) != NULL)

git-grep -n -A2 "while" | 
sed -n "s/^\([^\.]*\.[chsS]-[0-9]*-\|\([^\.]*\.[chsS]:[0-9]*:\)$s\)\(.*\)$/\2\3/p" |
tr "\n" "@" |
grep -o "@[^@]*while$z($z($z$W$z=$z$W$z($h)$z)$z\!=${z}NULL$z)" |
tr "@\t" " " | tr -s " " | wc -l
333

# while ((x = y(...)) != 0)

git-grep -n -A2 "while" | 
sed -n "s/^\([^\.]*\.[chsS]-[0-9]*-\|\([^\.]*\.[chsS]:[0-9]*:\)$s\)\(.*\)$/\2\3/p" |
tr "\n" "@" |
grep -o "@[^@]*while$z($z($z$W$z=$z$W$z($h)$z)$z\!=${z}0$z)" |
tr "@\t" " " | tr -s " " | wc -l
45

# while (!(x = y(...)))

git-grep -n -A2 "while" | 
sed -n "s/^\([^\.]*\.[chsS]-[0-9]*-\|\([^\.]*\.[chsS]:[0-9]*:\)$s\)\(.*\)$/\2\3/p" |
tr "\n" "@" |
grep -o "@[^@]*while$z($z\!$z($z$W$z=$z$W$z($h)$z)$z)" |
tr "@\t" " " | tr -s " " | wc -l
19


V="[A-Za-z_]\+[A-Za-z0-9_]*"
W="$V\(\[$V\]\|\[[0-9]\+\]\|\.$V\|->$V\)*"
s="[[:space:]]*"
h="[^()]*\(([^()]*)[^()]*\)*"
z="[@[:space:]]*"

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2008-02-16 12:04 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <200802160449.m1G4nX5V009024@imap1.linux-foundation.org>
2008-02-16  9:27 ` + bluetooth-fix-warning-in-net-bluetooth-hci_sysfsc.patch added to -mm tree David Miller
2008-02-16  9:54   ` Andrew Morton
2008-02-16 12:03     ` Roel Kluin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).