* checkpatch not warning for some split strings
@ 2013-12-02 21:23 Joe Perches
2013-12-02 21:33 ` Josh Triplett
0 siblings, 1 reply; 4+ messages in thread
From: Joe Perches @ 2013-12-02 21:23 UTC (permalink / raw)
To: Josh Triplett; +Cc: LKML, Andrew Morton, Andy Whitcroft
Hey Josh.
Back when you added commit ca56dc098ca
("checkpatch: check for quoted strings broken across lines")
You added this test case:
Test case:
void context(void)
{
struct { unsigned magic; const char *strdata; } foo[] = {
{ 42, "these strings"
"do not produce warnings" },
{ 256, "though perhaps"
"they should" },
};
which avoids emitting a warning on split strings across
multiple lines without a function-call like '(' use on
the line above.
Perhaps the "\(" test should be removed as checkpatch
doesn't emit a warning for some uses like:
diff --git a/drivers/net/wireless/iwlwifi/mvm/rs.c b/drivers/net/wireless/iwlwifi/mvm/rs.c
[]
@@ -1868,7 +1865,8 @@ static void rs_rate_scale_perform(struct iwl_mvm *mvm,
/* Else poor success; go back to mode in "active" table */
} else {
IWL_DEBUG_RATE(mvm,
- "LQ: GOING BACK TO THE OLD TABLE suc=%d cur-tpt=%d old-tpt=%d\n",
+ "GOING BACK TO THE OLD TABLE: SR %d "
+ "cur-tpt %d old-tpt %d\n",
window->success_ratio,
window->average_tpt,
lq_sta->last_tpt);
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: checkpatch not warning for some split strings
2013-12-02 21:23 checkpatch not warning for some split strings Joe Perches
@ 2013-12-02 21:33 ` Josh Triplett
2013-12-03 5:44 ` [PATCH] checkpatch: More comprehensive split strings warning Joe Perches
0 siblings, 1 reply; 4+ messages in thread
From: Josh Triplett @ 2013-12-02 21:33 UTC (permalink / raw)
To: Joe Perches; +Cc: LKML, Andrew Morton, Andy Whitcroft
On Mon, Dec 02, 2013 at 01:23:58PM -0800, Joe Perches wrote:
> Hey Josh.
>
> Back when you added commit ca56dc098ca
> ("checkpatch: check for quoted strings broken across lines")
>
> You added this test case:
>
> Test case:
>
> void context(void)
> {
> struct { unsigned magic; const char *strdata; } foo[] = {
> { 42, "these strings"
> "do not produce warnings" },
> { 256, "though perhaps"
> "they should" },
> };
>
> which avoids emitting a warning on split strings across
> multiple lines without a function-call like '(' use on
> the line above.
>
> Perhaps the "\(" test should be removed as checkpatch
> doesn't emit a warning for some uses like:
>
> diff --git a/drivers/net/wireless/iwlwifi/mvm/rs.c b/drivers/net/wireless/iwlwifi/mvm/rs.c
> []
> @@ -1868,7 +1865,8 @@ static void rs_rate_scale_perform(struct iwl_mvm *mvm,
> /* Else poor success; go back to mode in "active" table */
> } else {
> IWL_DEBUG_RATE(mvm,
> - "LQ: GOING BACK TO THE OLD TABLE suc=%d cur-tpt=%d old-tpt=%d\n",
> + "GOING BACK TO THE OLD TABLE: SR %d "
> + "cur-tpt %d old-tpt %d\n",
> window->success_ratio,
> window->average_tpt,
> lq_sta->last_tpt);
That one should definitely emit a warning. However, removing the \(
test entirely will introduce warnings on many other strings embedded in
data structures; only drop that test if you've diffed the checkpatch
output for the kernel with and without it and you're comfortable with
the *huge* number of additional warnings it'll introduce.
- Josh Triplett
^ permalink raw reply [flat|nested] 4+ messages in thread* [PATCH] checkpatch: More comprehensive split strings warning
2013-12-02 21:33 ` Josh Triplett
@ 2013-12-03 5:44 ` Joe Perches
2013-12-03 8:56 ` Josh Triplett
0 siblings, 1 reply; 4+ messages in thread
From: Joe Perches @ 2013-12-03 5:44 UTC (permalink / raw)
To: Josh Triplett; +Cc: LKML, Andrew Morton, Andy Whitcroft
The current checkpatch test for split strings does
not find several cases that should be found.
For instance:
diff --git a/drivers/net/wireless/iwlwifi/mvm/rs.c b/drivers/net/wireless/iwlwifi/mvm/rs.c
[]
@@ -1868,7 +1865,8 @@ static void rs_rate_scale_perform(struct iwl_mvm *mvm,
/* Else poor success; go back to mode in "active" table */
} else {
IWL_DEBUG_RATE(mvm,
- "LQ: GOING BACK TO THE OLD TABLE suc=%d cur-tpt=%d old-tpt=%d\n",
+ "GOING BACK TO THE OLD TABLE: SR %d "
+ "cur-tpt %d old-tpt %d\n",
window->success_ratio,
window->average_tpt,
lq_sta->last_tpt);
does not currently emit a warning.
Improve the test to find these cases.
Add more exceptions to reduce false positives for
assembly and octal/hex string constants.
Signed-off-by: Joe Perches <joe@perches.com>
---
scripts/checkpatch.pl | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 38be5d5..1d0d5ac 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -2049,16 +2049,12 @@ sub process {
}
# Check for user-visible strings broken across lines, which breaks the ability
-# to grep for the string. Limited to strings used as parameters (those
-# following an open parenthesis), which almost completely eliminates false
-# positives, as well as warning only once per parameter rather than once per
-# line of the string. Make an exception when the previous string ends in a
-# newline (multiple lines in one string constant) or \n\t (common in inline
-# assembly to indent the instruction on the following line).
+# to grep for the string. Make exceptions when the previous string ends in a
+# newline (multiple lines in one string constant) or '\t', '\r', ';', or '{'
+# (common in inline assembly) or is a octal \123 or hexadecimal \xaf value
if ($line =~ /^\+\s*"/ &&
$prevline =~ /"\s*$/ &&
- $prevline =~ /\(/ &&
- $prevrawline !~ /\\n(?:\\t)*"\s*$/) {
+ $prevrawline !~ /(?:\\(?:[ntr]|[0-7]{1,3}|x[0-9a-fA-F]{1,2})|;\s*|\{\s*)"\s*$/) {
WARN("SPLIT_STRING",
"quoted string split across lines\n" . $hereprev);
}
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH] checkpatch: More comprehensive split strings warning
2013-12-03 5:44 ` [PATCH] checkpatch: More comprehensive split strings warning Joe Perches
@ 2013-12-03 8:56 ` Josh Triplett
0 siblings, 0 replies; 4+ messages in thread
From: Josh Triplett @ 2013-12-03 8:56 UTC (permalink / raw)
To: Joe Perches; +Cc: LKML, Andrew Morton, Andy Whitcroft
On Mon, Dec 02, 2013 at 09:44:17PM -0800, Joe Perches wrote:
> The current checkpatch test for split strings does
> not find several cases that should be found.
>
> For instance:
>
> diff --git a/drivers/net/wireless/iwlwifi/mvm/rs.c b/drivers/net/wireless/iwlwifi/mvm/rs.c
> []
> @@ -1868,7 +1865,8 @@ static void rs_rate_scale_perform(struct iwl_mvm *mvm,
> /* Else poor success; go back to mode in "active" table */
> } else {
> IWL_DEBUG_RATE(mvm,
> - "LQ: GOING BACK TO THE OLD TABLE suc=%d cur-tpt=%d old-tpt=%d\n",
> + "GOING BACK TO THE OLD TABLE: SR %d "
> + "cur-tpt %d old-tpt %d\n",
> window->success_ratio,
> window->average_tpt,
> lq_sta->last_tpt);
>
> does not currently emit a warning.
>
> Improve the test to find these cases.
>
> Add more exceptions to reduce false positives for
> assembly and octal/hex string constants.
Nice choice of exceptions; that should work quite well.
> Signed-off-by: Joe Perches <joe@perches.com>
Reviewed-by: Josh Triplett <josh@joshtriplett.org>
> scripts/checkpatch.pl | 12 ++++--------
> 1 file changed, 4 insertions(+), 8 deletions(-)
>
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> index 38be5d5..1d0d5ac 100755
> --- a/scripts/checkpatch.pl
> +++ b/scripts/checkpatch.pl
> @@ -2049,16 +2049,12 @@ sub process {
> }
>
> # Check for user-visible strings broken across lines, which breaks the ability
> -# to grep for the string. Limited to strings used as parameters (those
> -# following an open parenthesis), which almost completely eliminates false
> -# positives, as well as warning only once per parameter rather than once per
> -# line of the string. Make an exception when the previous string ends in a
> -# newline (multiple lines in one string constant) or \n\t (common in inline
> -# assembly to indent the instruction on the following line).
> +# to grep for the string. Make exceptions when the previous string ends in a
> +# newline (multiple lines in one string constant) or '\t', '\r', ';', or '{'
> +# (common in inline assembly) or is a octal \123 or hexadecimal \xaf value
> if ($line =~ /^\+\s*"/ &&
> $prevline =~ /"\s*$/ &&
> - $prevline =~ /\(/ &&
> - $prevrawline !~ /\\n(?:\\t)*"\s*$/) {
> + $prevrawline !~ /(?:\\(?:[ntr]|[0-7]{1,3}|x[0-9a-fA-F]{1,2})|;\s*|\{\s*)"\s*$/) {
> WARN("SPLIT_STRING",
> "quoted string split across lines\n" . $hereprev);
> }
>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2013-12-03 8:56 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-02 21:23 checkpatch not warning for some split strings Joe Perches
2013-12-02 21:33 ` Josh Triplett
2013-12-03 5:44 ` [PATCH] checkpatch: More comprehensive split strings warning Joe Perches
2013-12-03 8:56 ` Josh Triplett
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox