Re: [PATCH v2] checkpatch: Suggest using min_t or max_t
On Thu, 2012-09-06 at 02:16 +0200, Philippe De Muyter wrote: > On Wed, Sep 5, 2012 at 7:07 PM, Joe Perches wrote: > > On Wed, 2012-09-05 at 13:21 +0200, Philippe De Muyter wrote: > >> > v2: Make $match_balanced_parentheses work in perl 5.8 > >> > >> Has this been applied ? > >> > >> v3.3 version of checkpatch.pl works for me, but v3.4, v3.5 & v3.6rc2 say: > >> Nested quantifiers in regex; marked by <-- HERE in m/(\((?:[^\(\)]++ > >> <-- HERE |(?-1))*\))/ at scripts/checkpatch.pl line 340. > >> > >> and my perl is : > >> > >> perl --version > >> > >> This is perl, v5.8.8 built for i586-linux-thread-multi > > > > The current version of checkpatch skips this > > check when the perl version is less than 5.10.0 > > > > > > commit d7c76ba7e58bc3ca674f20759c686535db484749 > > Author: Joe Perches > > Date: Tue Jan 10 15:09:58 2012 -0800 > > > > checkpatch: improve memset and min/max with cast checking > > > > Improve the checking of arguments to memset and min/max tests. > > > > Move the checking of min/max to statement blocks instead of single line. > > Change $Constant to allow any case type 0x initiator and trailing ul > > specifier. Add $FuncArg type as any function argument with or without a > > cast. Print the whole statement when showing memset or min/max > > messages. > > Improve the memset with 0 as 3rd argument error message. > > > > There are still weaknesses in the $FuncArg and $Constant code as > > arbitrary > > parentheses and negative signs are not generically supported. > > > > [] > > # Using $balanced_parens, $LvalOrFunc, or $FuncArg > > # requires at least perl version v5.10.0 > > # Any use must be runtime checked with $^V > > [] > > # typecasts on min/max could be min_t/max_t > > if ($^V && $^V ge 5.10.0 && > > defined $stat && > > $stat =~ > > /^\+(?:.*?)\b(min|max)\s*\(\s*$FuncArg\s*,\s*$FuncArg\s*\)/) { > > > > > > I know nothing about perl, and when I read 3.6rc2's checkpatch.pl it > seems to me that every usage of $balanced_parens, $LvalOrFunc, or > $FuncArg is protected by a test for v5.10.0, but line 340, which perl > complains about, is not a use, but merely a definition. Should the > definition not be protected too ? Beats me. I'm not a perl monk either. Maybe it should. I don't have 5.8 and the latest is 5.16. 5.8 is pretty old. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH v2] checkpatch: Suggest using min_t or max_t
On Wed, Sep 5, 2012 at 7:07 PM, Joe Perches wrote: > On Wed, 2012-09-05 at 13:21 +0200, Philippe De Muyter wrote: >> > v2: Make $match_balanced_parentheses work in perl 5.8 >> >> Has this been applied ? >> >> v3.3 version of checkpatch.pl works for me, but v3.4, v3.5 & v3.6rc2 say: >> Nested quantifiers in regex; marked by <-- HERE in m/(\((?:[^\(\)]++ >> <-- HERE |(?-1))*\))/ at scripts/checkpatch.pl line 340. >> >> and my perl is : >> >> perl --version >> >> This is perl, v5.8.8 built for i586-linux-thread-multi > > The current version of checkpatch skips this > check when the perl version is less than 5.10.0 > > > commit d7c76ba7e58bc3ca674f20759c686535db484749 > Author: Joe Perches > Date: Tue Jan 10 15:09:58 2012 -0800 > > checkpatch: improve memset and min/max with cast checking > > Improve the checking of arguments to memset and min/max tests. > > Move the checking of min/max to statement blocks instead of single line. > Change $Constant to allow any case type 0x initiator and trailing ul > specifier. Add $FuncArg type as any function argument with or without a > cast. Print the whole statement when showing memset or min/max messages. > Improve the memset with 0 as 3rd argument error message. > > There are still weaknesses in the $FuncArg and $Constant code as arbitrary > parentheses and negative signs are not generically supported. > > [] > # Using $balanced_parens, $LvalOrFunc, or $FuncArg > # requires at least perl version v5.10.0 > # Any use must be runtime checked with $^V > [] > # typecasts on min/max could be min_t/max_t > if ($^V && $^V ge 5.10.0 && > defined $stat && > $stat =~ > /^\+(?:.*?)\b(min|max)\s*\(\s*$FuncArg\s*,\s*$FuncArg\s*\)/) { > > I know nothing about perl, and when I read 3.6rc2's checkpatch.pl it seems to me that every usage of $balanced_parens, $LvalOrFunc, or $FuncArg is protected by a test for v5.10.0, but line 340, which perl complains about, is not a use, but merely a definition. Should the definition not be protected too ? Philippe -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH v2] checkpatch: Suggest using min_t or max_t
On Wed, 2012-09-05 at 13:21 +0200, Philippe De Muyter wrote: > On 5/27/11, Joe Perches wrote: > > A common issue with min() or max() is using a cast on > > one or both of the arguments when using min_t/max_t could > > be better. > > > > Add cast detection to uses of min/max and suggest an > > appropriate use of min_t or max_t instead. > > > > Caveat: This only works for min() or max() on a single line. > > It does not find min() or max() split across multiple lines. > > > > This does find: > > min((u32)foo, bar); > > But it does not find: > > max((unsigned long)foo, > > bar); > > > > Suggested-by: Andrew Morton > > Signed-off-by: Joe Perches > > --- > > > > v2: Make $match_balanced_parentheses work in perl 5.8 > > Has this been applied ? > > v3.3 version of checkpatch.pl works for me, but v3.4, v3.5 & v3.6rc2 say: > Nested quantifiers in regex; marked by <-- HERE in m/(\((?:[^\(\)]++ > <-- HERE |(?-1))*\))/ at scripts/checkpatch.pl line 340. > > and my perl is : > > perl --version > > This is perl, v5.8.8 built for i586-linux-thread-multi The current version of checkpatch skips this check when the perl version is less than 5.10.0 commit d7c76ba7e58bc3ca674f20759c686535db484749 Author: Joe Perches Date: Tue Jan 10 15:09:58 2012 -0800 checkpatch: improve memset and min/max with cast checking Improve the checking of arguments to memset and min/max tests. Move the checking of min/max to statement blocks instead of single line. Change $Constant to allow any case type 0x initiator and trailing ul specifier. Add $FuncArg type as any function argument with or without a cast. Print the whole statement when showing memset or min/max messages. Improve the memset with 0 as 3rd argument error message. There are still weaknesses in the $FuncArg and $Constant code as arbitrary parentheses and negative signs are not generically supported. [] # Using $balanced_parens, $LvalOrFunc, or $FuncArg # requires at least perl version v5.10.0 # Any use must be runtime checked with $^V [] # typecasts on min/max could be min_t/max_t if ($^V && $^V ge 5.10.0 && defined $stat && $stat =~ /^\+(?:.*?)\b(min|max)\s*\(\s*$FuncArg\s*,\s*$FuncArg\s*\)/) { -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH v2] checkpatch: Suggest using min_t or max_t
On 5/27/11, Joe Perches wrote: > A common issue with min() or max() is using a cast on > one or both of the arguments when using min_t/max_t could > be better. > > Add cast detection to uses of min/max and suggest an > appropriate use of min_t or max_t instead. > > Caveat: This only works for min() or max() on a single line. > It does not find min() or max() split across multiple lines. > > This does find: > min((u32)foo, bar); > But it does not find: > max((unsigned long)foo, > bar); > > Suggested-by: Andrew Morton > Signed-off-by: Joe Perches > --- > > v2: Make $match_balanced_parentheses work in perl 5.8 Has this been applied ? v3.3 version of checkpatch.pl works for me, but v3.4, v3.5 & v3.6rc2 say: Nested quantifiers in regex; marked by <-- HERE in m/(\((?:[^\(\)]++ <-- HERE |(?-1))*\))/ at scripts/checkpatch.pl line 340. and my perl is : perl --version This is perl, v5.8.8 built for i586-linux-thread-multi Philippe -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH v2] checkpatch: Suggest using min_t or max_t
On Wed, Sep 5, 2012 at 7:07 PM, Joe Perches j...@perches.com wrote: On Wed, 2012-09-05 at 13:21 +0200, Philippe De Muyter wrote: v2: Make $match_balanced_parentheses work in perl 5.8 Has this been applied ? v3.3 version of checkpatch.pl works for me, but v3.4, v3.5 v3.6rc2 say: Nested quantifiers in regex; marked by -- HERE in m/(\((?:[^\(\)]++ -- HERE |(?-1))*\))/ at scripts/checkpatch.pl line 340. and my perl is : perl --version This is perl, v5.8.8 built for i586-linux-thread-multi The current version of checkpatch skips this check when the perl version is less than 5.10.0 commit d7c76ba7e58bc3ca674f20759c686535db484749 Author: Joe Perches j...@perches.com Date: Tue Jan 10 15:09:58 2012 -0800 checkpatch: improve memset and min/max with cast checking Improve the checking of arguments to memset and min/max tests. Move the checking of min/max to statement blocks instead of single line. Change $Constant to allow any case type 0x initiator and trailing ul specifier. Add $FuncArg type as any function argument with or without a cast. Print the whole statement when showing memset or min/max messages. Improve the memset with 0 as 3rd argument error message. There are still weaknesses in the $FuncArg and $Constant code as arbitrary parentheses and negative signs are not generically supported. [] # Using $balanced_parens, $LvalOrFunc, or $FuncArg # requires at least perl version v5.10.0 # Any use must be runtime checked with $^V [] # typecasts on min/max could be min_t/max_t if ($^V $^V ge 5.10.0 defined $stat $stat =~ /^\+(?:.*?)\b(min|max)\s*\(\s*$FuncArg\s*,\s*$FuncArg\s*\)/) { I know nothing about perl, and when I read 3.6rc2's checkpatch.pl it seems to me that every usage of $balanced_parens, $LvalOrFunc, or $FuncArg is protected by a test for v5.10.0, but line 340, which perl complains about, is not a use, but merely a definition. Should the definition not be protected too ? Philippe -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH v2] checkpatch: Suggest using min_t or max_t
On Thu, 2012-09-06 at 02:16 +0200, Philippe De Muyter wrote: On Wed, Sep 5, 2012 at 7:07 PM, Joe Perches j...@perches.com wrote: On Wed, 2012-09-05 at 13:21 +0200, Philippe De Muyter wrote: v2: Make $match_balanced_parentheses work in perl 5.8 Has this been applied ? v3.3 version of checkpatch.pl works for me, but v3.4, v3.5 v3.6rc2 say: Nested quantifiers in regex; marked by -- HERE in m/(\((?:[^\(\)]++ -- HERE |(?-1))*\))/ at scripts/checkpatch.pl line 340. and my perl is : perl --version This is perl, v5.8.8 built for i586-linux-thread-multi The current version of checkpatch skips this check when the perl version is less than 5.10.0 commit d7c76ba7e58bc3ca674f20759c686535db484749 Author: Joe Perches j...@perches.com Date: Tue Jan 10 15:09:58 2012 -0800 checkpatch: improve memset and min/max with cast checking Improve the checking of arguments to memset and min/max tests. Move the checking of min/max to statement blocks instead of single line. Change $Constant to allow any case type 0x initiator and trailing ul specifier. Add $FuncArg type as any function argument with or without a cast. Print the whole statement when showing memset or min/max messages. Improve the memset with 0 as 3rd argument error message. There are still weaknesses in the $FuncArg and $Constant code as arbitrary parentheses and negative signs are not generically supported. [] # Using $balanced_parens, $LvalOrFunc, or $FuncArg # requires at least perl version v5.10.0 # Any use must be runtime checked with $^V [] # typecasts on min/max could be min_t/max_t if ($^V $^V ge 5.10.0 defined $stat $stat =~ /^\+(?:.*?)\b(min|max)\s*\(\s*$FuncArg\s*,\s*$FuncArg\s*\)/) { I know nothing about perl, and when I read 3.6rc2's checkpatch.pl it seems to me that every usage of $balanced_parens, $LvalOrFunc, or $FuncArg is protected by a test for v5.10.0, but line 340, which perl complains about, is not a use, but merely a definition. Should the definition not be protected too ? Beats me. I'm not a perl monk either. Maybe it should. I don't have 5.8 and the latest is 5.16. 5.8 is pretty old. -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH v2] checkpatch: Suggest using min_t or max_t
On 5/27/11, Joe Perches j...@perches.com wrote: A common issue with min() or max() is using a cast on one or both of the arguments when using min_t/max_t could be better. Add cast detection to uses of min/max and suggest an appropriate use of min_t or max_t instead. Caveat: This only works for min() or max() on a single line. It does not find min() or max() split across multiple lines. This does find: min((u32)foo, bar); But it does not find: max((unsigned long)foo, bar); Suggested-by: Andrew Morton a...@linux-foundation.org Signed-off-by: Joe Perches j...@perches.com --- v2: Make $match_balanced_parentheses work in perl 5.8 Has this been applied ? v3.3 version of checkpatch.pl works for me, but v3.4, v3.5 v3.6rc2 say: Nested quantifiers in regex; marked by -- HERE in m/(\((?:[^\(\)]++ -- HERE |(?-1))*\))/ at scripts/checkpatch.pl line 340. and my perl is : perl --version This is perl, v5.8.8 built for i586-linux-thread-multi Philippe -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH v2] checkpatch: Suggest using min_t or max_t
On Wed, 2012-09-05 at 13:21 +0200, Philippe De Muyter wrote: On 5/27/11, Joe Perches j...@perches.com wrote: A common issue with min() or max() is using a cast on one or both of the arguments when using min_t/max_t could be better. Add cast detection to uses of min/max and suggest an appropriate use of min_t or max_t instead. Caveat: This only works for min() or max() on a single line. It does not find min() or max() split across multiple lines. This does find: min((u32)foo, bar); But it does not find: max((unsigned long)foo, bar); Suggested-by: Andrew Morton a...@linux-foundation.org Signed-off-by: Joe Perches j...@perches.com --- v2: Make $match_balanced_parentheses work in perl 5.8 Has this been applied ? v3.3 version of checkpatch.pl works for me, but v3.4, v3.5 v3.6rc2 say: Nested quantifiers in regex; marked by -- HERE in m/(\((?:[^\(\)]++ -- HERE |(?-1))*\))/ at scripts/checkpatch.pl line 340. and my perl is : perl --version This is perl, v5.8.8 built for i586-linux-thread-multi The current version of checkpatch skips this check when the perl version is less than 5.10.0 commit d7c76ba7e58bc3ca674f20759c686535db484749 Author: Joe Perches j...@perches.com Date: Tue Jan 10 15:09:58 2012 -0800 checkpatch: improve memset and min/max with cast checking Improve the checking of arguments to memset and min/max tests. Move the checking of min/max to statement blocks instead of single line. Change $Constant to allow any case type 0x initiator and trailing ul specifier. Add $FuncArg type as any function argument with or without a cast. Print the whole statement when showing memset or min/max messages. Improve the memset with 0 as 3rd argument error message. There are still weaknesses in the $FuncArg and $Constant code as arbitrary parentheses and negative signs are not generically supported. [] # Using $balanced_parens, $LvalOrFunc, or $FuncArg # requires at least perl version v5.10.0 # Any use must be runtime checked with $^V [] # typecasts on min/max could be min_t/max_t if ($^V $^V ge 5.10.0 defined $stat $stat =~ /^\+(?:.*?)\b(min|max)\s*\(\s*$FuncArg\s*,\s*$FuncArg\s*\)/) { -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/