* [Linux-kernel-mentees] [PATCH] checkpatch: trivial style fixes
@ 2021-01-04 13:25 Dwaipayan Ray
2021-01-04 13:25 ` [Linux-kernel-mentees] [PATCH] checkpatch: add a new check for strcpy/strlcpy uses Dwaipayan Ray
2021-01-05 8:04 ` [Linux-kernel-mentees] [PATCH] checkpatch: trivial style fixes Lukas Bulwahn
0 siblings, 2 replies; 10+ messages in thread
From: Dwaipayan Ray @ 2021-01-04 13:25 UTC (permalink / raw)
To: lukas.bulwahn; +Cc: dwaipayanray1, linux-kernel-mentees
Indentations should use tabs wherever possible.
Replace spaces by tabs for indents.
Signed-off-by: Dwaipayan Ray <dwaipayanray1@gmail.com>
---
scripts/checkpatch.pl | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index b212f5f12ca6..d6a4d25b0972 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -2973,7 +2973,7 @@ sub process {
}
if (!defined $lines[$linenr]) {
WARN("BAD_SIGN_OFF",
- "Co-developed-by: must be immediately followed by Signed-off-by:\n" . "$here\n" . $rawline);
+ "Co-developed-by: must be immediately followed by Signed-off-by:\n" . "$here\n" . $rawline);
} elsif ($rawlines[$linenr] !~ /^\s*signed-off-by:\s*(.*)/i) {
WARN("BAD_SIGN_OFF",
"Co-developed-by: must be immediately followed by Signed-off-by:\n" . "$here\n" . $rawline . "\n" .$rawlines[$linenr]);
@@ -2996,8 +2996,8 @@ sub process {
if (ERROR("GERRIT_CHANGE_ID",
"Remove Gerrit Change-Id's before submitting upstream\n" . $herecurr) &&
$fix) {
- fix_delete_line($fixlinenr, $rawline);
- }
+ fix_delete_line($fixlinenr, $rawline);
+ }
}
# Check if the commit log is in a possible stack dump
@@ -3239,10 +3239,10 @@ sub process {
next if ($start_char =~ /^\S$/);
next if (index(" \t.,;?!", $end_char) == -1);
- # avoid repeating hex occurrences like 'ff ff fe 09 ...'
- if ($first =~ /\b[0-9a-f]{2,}\b/i) {
- next if (!exists($allow_repeated_words{lc($first)}));
- }
+ # avoid repeating hex occurrences like 'ff ff fe 09 ...'
+ if ($first =~ /\b[0-9a-f]{2,}\b/i) {
+ next if (!exists($allow_repeated_words{lc($first)}));
+ }
if (WARN("REPEATED_WORD",
"Possible repeated word: '$first'\n" . $herecurr) &&
@@ -4426,7 +4426,7 @@ sub process {
WARN("STATIC_CONST_CHAR_ARRAY",
"char * array declaration might be better as static const\n" .
$herecurr);
- }
+ }
# check for sizeof(foo)/sizeof(foo[0]) that could be ARRAY_SIZE(foo)
if ($line =~ m@\bsizeof\s*\(\s*($Lval)\s*\)@) {
@@ -5279,7 +5279,7 @@ sub process {
$lines[$linenr - 3] !~ /^[ +]\s*$Ident\s*:/) {
WARN("RETURN_VOID",
"void function return statements are not generally useful\n" . $hereprev);
- }
+ }
# if statements using unnecessary parentheses - ie: if ((foo == bar))
if ($perl_version_ok &&
--
2.27.0
_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [Linux-kernel-mentees] [PATCH] checkpatch: add a new check for strcpy/strlcpy uses
2021-01-04 13:25 [Linux-kernel-mentees] [PATCH] checkpatch: trivial style fixes Dwaipayan Ray
@ 2021-01-04 13:25 ` Dwaipayan Ray
2021-01-05 8:02 ` Lukas Bulwahn
2021-01-05 8:04 ` [Linux-kernel-mentees] [PATCH] checkpatch: trivial style fixes Lukas Bulwahn
1 sibling, 1 reply; 10+ messages in thread
From: Dwaipayan Ray @ 2021-01-04 13:25 UTC (permalink / raw)
To: lukas.bulwahn; +Cc: dwaipayanray1, linux-kernel-mentees
strcpy() performs no bounds checking on the destination buffer.
This could result in linear overflows beyond the end of the buffer.
strlcpy() reads the entire source buffer first. This read
may exceed the destination size limit. This can be both inefficient
and lead to linear read overflows.
The safe replacement to both of these is to use strscpy() instead.
Add a new checkpatch warning which alerts the user on finding usage of
strcpy() or strlcpy().
Signed-off-by: Dwaipayan Ray <dwaipayanray1@gmail.com>
---
scripts/checkpatch.pl | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index d6a4d25b0972..0003fd9de62c 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -6604,6 +6604,13 @@ sub process {
}
}
+# Check for strcpy/strlcpy uses
+ if (defined($stat) &&
+ $stat =~ /^\+(?:.*?)\b(str[l]?cpy)\s*\(/) {
+ WARN("PREFER_STRSCPY",
+ "Prefer strscpy() over $1()\n" . "$here\n$stat\n");
+ }
+
# Check for memcpy(foo, bar, ETH_ALEN) that could be ether_addr_copy(foo, bar)
# if ($perl_version_ok &&
# defined $stat &&
--
2.27.0
_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [Linux-kernel-mentees] [PATCH] checkpatch: add a new check for strcpy/strlcpy uses
2021-01-04 13:25 ` [Linux-kernel-mentees] [PATCH] checkpatch: add a new check for strcpy/strlcpy uses Dwaipayan Ray
@ 2021-01-05 8:02 ` Lukas Bulwahn
2021-01-05 8:19 ` Dwaipayan Ray
0 siblings, 1 reply; 10+ messages in thread
From: Lukas Bulwahn @ 2021-01-05 8:02 UTC (permalink / raw)
To: Dwaipayan Ray; +Cc: linux-kernel-mentees
On Mon, Jan 4, 2021 at 2:25 PM Dwaipayan Ray <dwaipayanray1@gmail.com> wrote:
>
> strcpy() performs no bounds checking on the destination buffer.
> This could result in linear overflows beyond the end of the buffer.
>
> strlcpy() reads the entire source buffer first. This read
> may exceed the destination size limit. This can be both inefficient
> and lead to linear read overflows.
>
> The safe replacement to both of these is to use strscpy() instead.
> Add a new checkpatch warning which alerts the user on finding usage of
> strcpy() or strlcpy().
>
> Signed-off-by: Dwaipayan Ray <dwaipayanray1@gmail.com>
> ---
I remember Joe has already created a patch for that over Christmas
break; check lkml before sending this.
Other than that, looks good.
Lukas
> scripts/checkpatch.pl | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> index d6a4d25b0972..0003fd9de62c 100755
> --- a/scripts/checkpatch.pl
> +++ b/scripts/checkpatch.pl
> @@ -6604,6 +6604,13 @@ sub process {
> }
> }
>
> +# Check for strcpy/strlcpy uses
> + if (defined($stat) &&
> + $stat =~ /^\+(?:.*?)\b(str[l]?cpy)\s*\(/) {
> + WARN("PREFER_STRSCPY",
> + "Prefer strscpy() over $1()\n" . "$here\n$stat\n");
> + }
> +
> # Check for memcpy(foo, bar, ETH_ALEN) that could be ether_addr_copy(foo, bar)
> # if ($perl_version_ok &&
> # defined $stat &&
> --
> 2.27.0
>
_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Linux-kernel-mentees] [PATCH] checkpatch: trivial style fixes
2021-01-04 13:25 [Linux-kernel-mentees] [PATCH] checkpatch: trivial style fixes Dwaipayan Ray
2021-01-04 13:25 ` [Linux-kernel-mentees] [PATCH] checkpatch: add a new check for strcpy/strlcpy uses Dwaipayan Ray
@ 2021-01-05 8:04 ` Lukas Bulwahn
2021-01-05 8:41 ` Dwaipayan Ray
1 sibling, 1 reply; 10+ messages in thread
From: Lukas Bulwahn @ 2021-01-05 8:04 UTC (permalink / raw)
To: Dwaipayan Ray; +Cc: linux-kernel-mentees
On Mon, Jan 4, 2021 at 2:25 PM Dwaipayan Ray <dwaipayanray1@gmail.com> wrote:
>
> Indentations should use tabs wherever possible.
> Replace spaces by tabs for indents.
>
> Signed-off-by: Dwaipayan Ray <dwaipayanray1@gmail.com>
Looks good.
Find out who is to blame for this stylistic mess up. (use git blame).
If it is Aditya, let him know to check better and how you discovered
this mess-up.
Lukas
> ---
> scripts/checkpatch.pl | 18 +++++++++---------
> 1 file changed, 9 insertions(+), 9 deletions(-)
>
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> index b212f5f12ca6..d6a4d25b0972 100755
> --- a/scripts/checkpatch.pl
> +++ b/scripts/checkpatch.pl
> @@ -2973,7 +2973,7 @@ sub process {
> }
> if (!defined $lines[$linenr]) {
> WARN("BAD_SIGN_OFF",
> - "Co-developed-by: must be immediately followed by Signed-off-by:\n" . "$here\n" . $rawline);
> + "Co-developed-by: must be immediately followed by Signed-off-by:\n" . "$here\n" . $rawline);
> } elsif ($rawlines[$linenr] !~ /^\s*signed-off-by:\s*(.*)/i) {
> WARN("BAD_SIGN_OFF",
> "Co-developed-by: must be immediately followed by Signed-off-by:\n" . "$here\n" . $rawline . "\n" .$rawlines[$linenr]);
> @@ -2996,8 +2996,8 @@ sub process {
> if (ERROR("GERRIT_CHANGE_ID",
> "Remove Gerrit Change-Id's before submitting upstream\n" . $herecurr) &&
> $fix) {
> - fix_delete_line($fixlinenr, $rawline);
> - }
> + fix_delete_line($fixlinenr, $rawline);
> + }
> }
>
> # Check if the commit log is in a possible stack dump
> @@ -3239,10 +3239,10 @@ sub process {
> next if ($start_char =~ /^\S$/);
> next if (index(" \t.,;?!", $end_char) == -1);
>
> - # avoid repeating hex occurrences like 'ff ff fe 09 ...'
> - if ($first =~ /\b[0-9a-f]{2,}\b/i) {
> - next if (!exists($allow_repeated_words{lc($first)}));
> - }
> + # avoid repeating hex occurrences like 'ff ff fe 09 ...'
> + if ($first =~ /\b[0-9a-f]{2,}\b/i) {
> + next if (!exists($allow_repeated_words{lc($first)}));
> + }
>
> if (WARN("REPEATED_WORD",
> "Possible repeated word: '$first'\n" . $herecurr) &&
> @@ -4426,7 +4426,7 @@ sub process {
> WARN("STATIC_CONST_CHAR_ARRAY",
> "char * array declaration might be better as static const\n" .
> $herecurr);
> - }
> + }
>
> # check for sizeof(foo)/sizeof(foo[0]) that could be ARRAY_SIZE(foo)
> if ($line =~ m@\bsizeof\s*\(\s*($Lval)\s*\)@) {
> @@ -5279,7 +5279,7 @@ sub process {
> $lines[$linenr - 3] !~ /^[ +]\s*$Ident\s*:/) {
> WARN("RETURN_VOID",
> "void function return statements are not generally useful\n" . $hereprev);
> - }
> + }
>
> # if statements using unnecessary parentheses - ie: if ((foo == bar))
> if ($perl_version_ok &&
> --
> 2.27.0
>
_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Linux-kernel-mentees] [PATCH] checkpatch: add a new check for strcpy/strlcpy uses
2021-01-05 8:02 ` Lukas Bulwahn
@ 2021-01-05 8:19 ` Dwaipayan Ray
2021-01-05 8:58 ` Lukas Bulwahn
0 siblings, 1 reply; 10+ messages in thread
From: Dwaipayan Ray @ 2021-01-05 8:19 UTC (permalink / raw)
To: Lukas Bulwahn; +Cc: linux-kernel-mentees
On Tue, Jan 5, 2021 at 1:32 PM Lukas Bulwahn <lukas.bulwahn@gmail.com> wrote:
>
> On Mon, Jan 4, 2021 at 2:25 PM Dwaipayan Ray <dwaipayanray1@gmail.com> wrote:
> >
> > strcpy() performs no bounds checking on the destination buffer.
> > This could result in linear overflows beyond the end of the buffer.
> >
> > strlcpy() reads the entire source buffer first. This read
> > may exceed the destination size limit. This can be both inefficient
> > and lead to linear read overflows.
> >
> > The safe replacement to both of these is to use strscpy() instead.
> > Add a new checkpatch warning which alerts the user on finding usage of
> > strcpy() or strlcpy().
> >
> > Signed-off-by: Dwaipayan Ray <dwaipayanray1@gmail.com>
> > ---
>
> I remember Joe has already created a patch for that over Christmas
> break; check lkml before sending this.
>
> Other than that, looks good.
>
> Lukas
Yes I found it:
https://lore.kernel.org/lkml/22b393d1790bb268769d0bab7bacf0866dcb0c14.camel@perches.com/
He has converted the uses in code. But I don't think he has created
the checkpatch rule yet. I will try sending it out to him.
Thank you,
Dwaipayan.
_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Linux-kernel-mentees] [PATCH] checkpatch: trivial style fixes
2021-01-05 8:04 ` [Linux-kernel-mentees] [PATCH] checkpatch: trivial style fixes Lukas Bulwahn
@ 2021-01-05 8:41 ` Dwaipayan Ray
2021-01-08 15:09 ` Aditya
0 siblings, 1 reply; 10+ messages in thread
From: Dwaipayan Ray @ 2021-01-05 8:41 UTC (permalink / raw)
To: Lukas Bulwahn, Aditya Srivastava; +Cc: linux-kernel-mentees
On Tue, Jan 5, 2021 at 1:34 PM Lukas Bulwahn <lukas.bulwahn@gmail.com> wrote:
>
> On Mon, Jan 4, 2021 at 2:25 PM Dwaipayan Ray <dwaipayanray1@gmail.com> wrote:
> >
> > Indentations should use tabs wherever possible.
> > Replace spaces by tabs for indents.
> >
> > Signed-off-by: Dwaipayan Ray <dwaipayanray1@gmail.com>
>
> Looks good.
>
> Find out who is to blame for this stylistic mess up. (use git blame).
>
> If it is Aditya, let him know to check better and how you discovered
> this mess-up.
>
I think some of Aditya's earlier patches caused this. I was idly running the
regex "^[ ]+" on files which detected these misuses. Probably it's a
broken editor
which expanded tabs, maybe vim with exandtab set. Aditya could you verify your
editor config? Thanks.
Thank you,
Dwaipayan.
>
> Lukas
>
> > ---
> > scripts/checkpatch.pl | 18 +++++++++---------
> > 1 file changed, 9 insertions(+), 9 deletions(-)
> >
> > diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> > index b212f5f12ca6..d6a4d25b0972 100755
> > --- a/scripts/checkpatch.pl
> > +++ b/scripts/checkpatch.pl
> > @@ -2973,7 +2973,7 @@ sub process {
> > }
> > if (!defined $lines[$linenr]) {
> > WARN("BAD_SIGN_OFF",
> > - "Co-developed-by: must be immediately followed by Signed-off-by:\n" . "$here\n" . $rawline);
> > + "Co-developed-by: must be immediately followed by Signed-off-by:\n" . "$here\n" . $rawline);
> > } elsif ($rawlines[$linenr] !~ /^\s*signed-off-by:\s*(.*)/i) {
> > WARN("BAD_SIGN_OFF",
> > "Co-developed-by: must be immediately followed by Signed-off-by:\n" . "$here\n" . $rawline . "\n" .$rawlines[$linenr]);
> > @@ -2996,8 +2996,8 @@ sub process {
> > if (ERROR("GERRIT_CHANGE_ID",
> > "Remove Gerrit Change-Id's before submitting upstream\n" . $herecurr) &&
> > $fix) {
> > - fix_delete_line($fixlinenr, $rawline);
> > - }
> > + fix_delete_line($fixlinenr, $rawline);
> > + }
> > }
> >
> > # Check if the commit log is in a possible stack dump
> > @@ -3239,10 +3239,10 @@ sub process {
> > next if ($start_char =~ /^\S$/);
> > next if (index(" \t.,;?!", $end_char) == -1);
> >
> > - # avoid repeating hex occurrences like 'ff ff fe 09 ...'
> > - if ($first =~ /\b[0-9a-f]{2,}\b/i) {
> > - next if (!exists($allow_repeated_words{lc($first)}));
> > - }
> > + # avoid repeating hex occurrences like 'ff ff fe 09 ...'
> > + if ($first =~ /\b[0-9a-f]{2,}\b/i) {
> > + next if (!exists($allow_repeated_words{lc($first)}));
> > + }
> >
> > if (WARN("REPEATED_WORD",
> > "Possible repeated word: '$first'\n" . $herecurr) &&
> > @@ -4426,7 +4426,7 @@ sub process {
> > WARN("STATIC_CONST_CHAR_ARRAY",
> > "char * array declaration might be better as static const\n" .
> > $herecurr);
> > - }
> > + }
> >
> > # check for sizeof(foo)/sizeof(foo[0]) that could be ARRAY_SIZE(foo)
> > if ($line =~ m@\bsizeof\s*\(\s*($Lval)\s*\)@) {
> > @@ -5279,7 +5279,7 @@ sub process {
> > $lines[$linenr - 3] !~ /^[ +]\s*$Ident\s*:/) {
> > WARN("RETURN_VOID",
> > "void function return statements are not generally useful\n" . $hereprev);
> > - }
> > + }
> >
> > # if statements using unnecessary parentheses - ie: if ((foo == bar))
> > if ($perl_version_ok &&
> > --
> > 2.27.0
> >
_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Linux-kernel-mentees] [PATCH] checkpatch: add a new check for strcpy/strlcpy uses
2021-01-05 8:19 ` Dwaipayan Ray
@ 2021-01-05 8:58 ` Lukas Bulwahn
0 siblings, 0 replies; 10+ messages in thread
From: Lukas Bulwahn @ 2021-01-05 8:58 UTC (permalink / raw)
To: Dwaipayan Ray; +Cc: linux-kernel-mentees
On Tue, Jan 5, 2021 at 9:19 AM Dwaipayan Ray <dwaipayanray1@gmail.com> wrote:
>
> On Tue, Jan 5, 2021 at 1:32 PM Lukas Bulwahn <lukas.bulwahn@gmail.com> wrote:
> >
> > On Mon, Jan 4, 2021 at 2:25 PM Dwaipayan Ray <dwaipayanray1@gmail.com> wrote:
> > >
> > > strcpy() performs no bounds checking on the destination buffer.
> > > This could result in linear overflows beyond the end of the buffer.
> > >
> > > strlcpy() reads the entire source buffer first. This read
> > > may exceed the destination size limit. This can be both inefficient
> > > and lead to linear read overflows.
> > >
> > > The safe replacement to both of these is to use strscpy() instead.
> > > Add a new checkpatch warning which alerts the user on finding usage of
> > > strcpy() or strlcpy().
> > >
> > > Signed-off-by: Dwaipayan Ray <dwaipayanray1@gmail.com>
> > > ---
> >
> > I remember Joe has already created a patch for that over Christmas
> > break; check lkml before sending this.
> >
> > Other than that, looks good.
> >
> > Lukas
>
> Yes I found it:
> https://lore.kernel.org/lkml/22b393d1790bb268769d0bab7bacf0866dcb0c14.camel@perches.com/
>
> He has converted the uses in code. But I don't think he has created
> the checkpatch rule yet. I will try sending it out to him.
>
Joe pointed you already to the commit. So I think your change is obsolete.
And I fully agree with Joe. strcpy is perfectly fine, when it is clear
from the use that boundaries do not need to be checked.
Lukas
_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Linux-kernel-mentees] [PATCH] checkpatch: trivial style fixes
2021-01-05 8:41 ` Dwaipayan Ray
@ 2021-01-08 15:09 ` Aditya
0 siblings, 0 replies; 10+ messages in thread
From: Aditya @ 2021-01-08 15:09 UTC (permalink / raw)
To: Dwaipayan Ray, Lukas Bulwahn; +Cc: linux-kernel-mentees
On 5/1/21 2:11 pm, Dwaipayan Ray wrote:
> On Tue, Jan 5, 2021 at 1:34 PM Lukas Bulwahn <lukas.bulwahn@gmail.com> wrote:
>>
>> On Mon, Jan 4, 2021 at 2:25 PM Dwaipayan Ray <dwaipayanray1@gmail.com> wrote:
>>>
>>> Indentations should use tabs wherever possible.
>>> Replace spaces by tabs for indents.
>>>
>>> Signed-off-by: Dwaipayan Ray <dwaipayanray1@gmail.com>
>>
>> Looks good.
>>
>> Find out who is to blame for this stylistic mess up. (use git blame).
>>
>> If it is Aditya, let him know to check better and how you discovered
>> this mess-up.
>>
>
> I think some of Aditya's earlier patches caused this. I was idly running the
> regex "^[ ]+" on files which detected these misuses. Probably it's a
> broken editor
> which expanded tabs, maybe vim with exandtab set. Aditya could you verify your
> editor config? Thanks.
>
Yes, this problem was there with my earlier setup, probably because of
configured tab size and word wrap. I think my current flow works better.
Thanks
Aditya
> Thank you,
> Dwaipayan.
>
>>
>> Lukas
>>
>>> ---
>>> scripts/checkpatch.pl | 18 +++++++++---------
>>> 1 file changed, 9 insertions(+), 9 deletions(-)
>>>
>>> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
>>> index b212f5f12ca6..d6a4d25b0972 100755
>>> --- a/scripts/checkpatch.pl
>>> +++ b/scripts/checkpatch.pl
>>> @@ -2973,7 +2973,7 @@ sub process {
>>> }
>>> if (!defined $lines[$linenr]) {
>>> WARN("BAD_SIGN_OFF",
>>> - "Co-developed-by: must be immediately followed by Signed-off-by:\n" . "$here\n" . $rawline);
>>> + "Co-developed-by: must be immediately followed by Signed-off-by:\n" . "$here\n" . $rawline);
>>> } elsif ($rawlines[$linenr] !~ /^\s*signed-off-by:\s*(.*)/i) {
>>> WARN("BAD_SIGN_OFF",
>>> "Co-developed-by: must be immediately followed by Signed-off-by:\n" . "$here\n" . $rawline . "\n" .$rawlines[$linenr]);
>>> @@ -2996,8 +2996,8 @@ sub process {
>>> if (ERROR("GERRIT_CHANGE_ID",
>>> "Remove Gerrit Change-Id's before submitting upstream\n" . $herecurr) &&
>>> $fix) {
>>> - fix_delete_line($fixlinenr, $rawline);
>>> - }
>>> + fix_delete_line($fixlinenr, $rawline);
>>> + }
>>> }
>>>
>>> # Check if the commit log is in a possible stack dump
>>> @@ -3239,10 +3239,10 @@ sub process {
>>> next if ($start_char =~ /^\S$/);
>>> next if (index(" \t.,;?!", $end_char) == -1);
>>>
>>> - # avoid repeating hex occurrences like 'ff ff fe 09 ...'
>>> - if ($first =~ /\b[0-9a-f]{2,}\b/i) {
>>> - next if (!exists($allow_repeated_words{lc($first)}));
>>> - }
>>> + # avoid repeating hex occurrences like 'ff ff fe 09 ...'
>>> + if ($first =~ /\b[0-9a-f]{2,}\b/i) {
>>> + next if (!exists($allow_repeated_words{lc($first)}));
>>> + }
>>>
>>> if (WARN("REPEATED_WORD",
>>> "Possible repeated word: '$first'\n" . $herecurr) &&
>>> @@ -4426,7 +4426,7 @@ sub process {
>>> WARN("STATIC_CONST_CHAR_ARRAY",
>>> "char * array declaration might be better as static const\n" .
>>> $herecurr);
>>> - }
>>> + }
>>>
>>> # check for sizeof(foo)/sizeof(foo[0]) that could be ARRAY_SIZE(foo)
>>> if ($line =~ m@\bsizeof\s*\(\s*($Lval)\s*\)@) {
>>> @@ -5279,7 +5279,7 @@ sub process {
>>> $lines[$linenr - 3] !~ /^[ +]\s*$Ident\s*:/) {
>>> WARN("RETURN_VOID",
>>> "void function return statements are not generally useful\n" . $hereprev);
>>> - }
>>> + }
>>>
>>> # if statements using unnecessary parentheses - ie: if ((foo == bar))
>>> if ($perl_version_ok &&
>>> --
>>> 2.27.0
>>>
_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Linux-kernel-mentees] [PATCH] checkpatch: trivial style fixes
2021-01-05 10:30 Dwaipayan Ray
@ 2021-01-05 10:37 ` Joe Perches
0 siblings, 0 replies; 10+ messages in thread
From: Joe Perches @ 2021-01-05 10:37 UTC (permalink / raw)
To: Dwaipayan Ray, Andrew Morton; +Cc: linux-kernel-mentees, linux-kernel
On Tue, 2021-01-05 at 16:00 +0530, Dwaipayan Ray wrote:
> Indentations should use tabs wherever possible.
> Replace spaces by tabs for indents.
Thanks.
Acked-by: Joe Perches <joe@perches.com>
>
> Signed-off-by: Dwaipayan Ray <dwaipayanray1@gmail.com>
> ---
> scripts/checkpatch.pl | 18 +++++++++---------
> 1 file changed, 9 insertions(+), 9 deletions(-)
>
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> index e6857bdfcb2d..7a323ca8a177 100755
> --- a/scripts/checkpatch.pl
> +++ b/scripts/checkpatch.pl
> @@ -2974,7 +2974,7 @@ sub process {
> }
> if (!defined $lines[$linenr]) {
> WARN("BAD_SIGN_OFF",
> - "Co-developed-by: must be immediately followed by Signed-off-by:\n" . "$here\n" . $rawline);
> + "Co-developed-by: must be immediately followed by Signed-off-by:\n" . "$here\n" . $rawline);
> } elsif ($rawlines[$linenr] !~ /^\s*signed-off-by:\s*(.*)/i) {
> WARN("BAD_SIGN_OFF",
> "Co-developed-by: must be immediately followed by Signed-off-by:\n" . "$here\n" . $rawline . "\n" .$rawlines[$linenr]);
> @@ -2997,8 +2997,8 @@ sub process {
> if (ERROR("GERRIT_CHANGE_ID",
> "Remove Gerrit Change-Id's before submitting upstream\n" . $herecurr) &&
> $fix) {
> - fix_delete_line($fixlinenr, $rawline);
> - }
> + fix_delete_line($fixlinenr, $rawline);
> + }
> }
>
>
> # Check if the commit log is in a possible stack dump
> @@ -3240,10 +3240,10 @@ sub process {
> next if ($start_char =~ /^\S$/);
> next if (index(" \t.,;?!", $end_char) == -1);
>
>
> - # avoid repeating hex occurrences like 'ff ff fe 09 ...'
> - if ($first =~ /\b[0-9a-f]{2,}\b/i) {
> - next if (!exists($allow_repeated_words{lc($first)}));
> - }
> + # avoid repeating hex occurrences like 'ff ff fe 09 ...'
> + if ($first =~ /\b[0-9a-f]{2,}\b/i) {
> + next if (!exists($allow_repeated_words{lc($first)}));
> + }
>
>
> if (WARN("REPEATED_WORD",
> "Possible repeated word: '$first'\n" . $herecurr) &&
> @@ -4432,7 +4432,7 @@ sub process {
> WARN("STATIC_CONST_CHAR_ARRAY",
> "char * array declaration might be better as static const\n" .
> $herecurr);
> - }
> + }
>
>
> # check for sizeof(foo)/sizeof(foo[0]) that could be ARRAY_SIZE(foo)
> if ($line =~ m@\bsizeof\s*\(\s*($Lval)\s*\)@) {
> @@ -5285,7 +5285,7 @@ sub process {
> $lines[$linenr - 3] !~ /^[ +]\s*$Ident\s*:/) {
> WARN("RETURN_VOID",
> "void function return statements are not generally useful\n" . $hereprev);
> - }
> + }
>
>
> # if statements using unnecessary parentheses - ie: if ((foo == bar))
> if ($perl_version_ok &&
_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Linux-kernel-mentees] [PATCH] checkpatch: trivial style fixes
@ 2021-01-05 10:30 Dwaipayan Ray
2021-01-05 10:37 ` Joe Perches
0 siblings, 1 reply; 10+ messages in thread
From: Dwaipayan Ray @ 2021-01-05 10:30 UTC (permalink / raw)
To: joe; +Cc: dwaipayanray1, linux-kernel-mentees, linux-kernel
Indentations should use tabs wherever possible.
Replace spaces by tabs for indents.
Signed-off-by: Dwaipayan Ray <dwaipayanray1@gmail.com>
---
scripts/checkpatch.pl | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index e6857bdfcb2d..7a323ca8a177 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -2974,7 +2974,7 @@ sub process {
}
if (!defined $lines[$linenr]) {
WARN("BAD_SIGN_OFF",
- "Co-developed-by: must be immediately followed by Signed-off-by:\n" . "$here\n" . $rawline);
+ "Co-developed-by: must be immediately followed by Signed-off-by:\n" . "$here\n" . $rawline);
} elsif ($rawlines[$linenr] !~ /^\s*signed-off-by:\s*(.*)/i) {
WARN("BAD_SIGN_OFF",
"Co-developed-by: must be immediately followed by Signed-off-by:\n" . "$here\n" . $rawline . "\n" .$rawlines[$linenr]);
@@ -2997,8 +2997,8 @@ sub process {
if (ERROR("GERRIT_CHANGE_ID",
"Remove Gerrit Change-Id's before submitting upstream\n" . $herecurr) &&
$fix) {
- fix_delete_line($fixlinenr, $rawline);
- }
+ fix_delete_line($fixlinenr, $rawline);
+ }
}
# Check if the commit log is in a possible stack dump
@@ -3240,10 +3240,10 @@ sub process {
next if ($start_char =~ /^\S$/);
next if (index(" \t.,;?!", $end_char) == -1);
- # avoid repeating hex occurrences like 'ff ff fe 09 ...'
- if ($first =~ /\b[0-9a-f]{2,}\b/i) {
- next if (!exists($allow_repeated_words{lc($first)}));
- }
+ # avoid repeating hex occurrences like 'ff ff fe 09 ...'
+ if ($first =~ /\b[0-9a-f]{2,}\b/i) {
+ next if (!exists($allow_repeated_words{lc($first)}));
+ }
if (WARN("REPEATED_WORD",
"Possible repeated word: '$first'\n" . $herecurr) &&
@@ -4432,7 +4432,7 @@ sub process {
WARN("STATIC_CONST_CHAR_ARRAY",
"char * array declaration might be better as static const\n" .
$herecurr);
- }
+ }
# check for sizeof(foo)/sizeof(foo[0]) that could be ARRAY_SIZE(foo)
if ($line =~ m@\bsizeof\s*\(\s*($Lval)\s*\)@) {
@@ -5285,7 +5285,7 @@ sub process {
$lines[$linenr - 3] !~ /^[ +]\s*$Ident\s*:/) {
WARN("RETURN_VOID",
"void function return statements are not generally useful\n" . $hereprev);
- }
+ }
# if statements using unnecessary parentheses - ie: if ((foo == bar))
if ($perl_version_ok &&
--
2.27.0
_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
^ permalink raw reply related [flat|nested] 10+ messages in thread
end of thread, other threads:[~2021-01-08 15:09 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-04 13:25 [Linux-kernel-mentees] [PATCH] checkpatch: trivial style fixes Dwaipayan Ray
2021-01-04 13:25 ` [Linux-kernel-mentees] [PATCH] checkpatch: add a new check for strcpy/strlcpy uses Dwaipayan Ray
2021-01-05 8:02 ` Lukas Bulwahn
2021-01-05 8:19 ` Dwaipayan Ray
2021-01-05 8:58 ` Lukas Bulwahn
2021-01-05 8:04 ` [Linux-kernel-mentees] [PATCH] checkpatch: trivial style fixes Lukas Bulwahn
2021-01-05 8:41 ` Dwaipayan Ray
2021-01-08 15:09 ` Aditya
2021-01-05 10:30 Dwaipayan Ray
2021-01-05 10:37 ` Joe Perches
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.