Re: + bluetooth-fix-warning-in-net-bluetooth-hci_sysfsc.patch added to -mm tree

Previous thread: [PATCH] iommu-helper: segment boundary limit should be a power of 2 by FUJITA Tomonori on Saturday, February 16, 2008 - 2:09 am. (1 message)

Next thread: cris/arch-v10/lib/string.c compile error by Adrian Bunk on Saturday, February 16, 2008 - 2:57 am. (3 messages)
From: David Miller
Date: Saturday, February 16, 2008 - 2:27 am

From: 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.
--

From: Andrew Morton
Date: Saturday, February 16, 2008 - 2:54 am

-	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)
--

From: Roel Kluin
Date: Saturday, February 16, 2008 - 5:03 am

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:]]*"
--

Previous thread: [PATCH] iommu-helper: segment boundary limit should be a power of 2 by FUJITA Tomonori on Saturday, February 16, 2008 - 2:09 am. (1 message)

Next thread: cris/arch-v10/lib/string.c compile error by Adrian Bunk on Saturday, February 16, 2008 - 2:57 am. (3 messages)