+ checkpatch-update-__attribute__sectionname-quote-removal.patch added to -mm tree
[email protected]
tree noticeThe patch titled
Subject: checkpatch: update __attribute__((section("name"))) quote removal
has been added to the -mm tree. Its filename is
checkpatch-update-__attribute__sectionname-quote-removal.patch
This patch should soon appear at
https://ozlabs.org/~akpm/mmots/broken-out/checkpatch-update-__attribute__sectionname-quote-removal.patch
and later at
https://ozlabs.org/~akpm/mmotm/broken-out/checkpatch-update-__attribute__sectionname-quote-removal.patch
Before you just go and hit "reply", please:
a) Consider who else should be cc'ed
b) Prefer to cc a suitable mailing list as well
c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's
*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***
The -mm tree is included into linux-next and is updated there every 3-4 working days
------------------------------------------------------
From: Joe Perches <[email protected]>
Subject: checkpatch: update __attribute__((section("name"))) quote removal
commit 33def8498fdd ("treewide: Convert macro and uses of __section(foo) to __section("foo")") removed the stringification of the section name and now requires quotes around the named section.
Update checkpatch to not remove any quotes when suggesting conversion of __attribute__((section("name"))) to __section("name")
Miscellanea:
o Add section to the hash with __section replacement
o Remove separate test for __attribute__((section
o Remove the limitation on converting attributes containing only known, possible conversions. Any unknown attribute types are now left as-is and known types are converted and moved before __attribute__ and removed from within the __attribute__((list...)).
---
scripts/checkpatch.pl | 46 +++++++++++++--------------------------- 1 file changed, 16 insertions(+), 30 deletions(-)
scripts/checkpatch.pl renamed from scripts/checkpatch.pl~checkpatch-update-__attribute__sectionname-quote-removal +16 -30
@@ -6216,51 +6216,37 @@ sub process { "noreturn" => "__noreturn", "packed" => "__packed", "pure" => "__pure", + "section" => "__section", "used" => "__used" ); - my @conv_array = (); - my $conv_possible = 1; - while ($attr =~ /\s*(\w+)\s*(${balanced_parens})?/g) { - my $curr_attr = $1; + my $orig_attr = $1; my $params = ''; $params = $2 if defined($2); + my $curr_attr = $orig_attr; $curr_attr =~ s/^[\s_]+|[\s_]+$//g; - if (exists($attr_list{$curr_attr})) { + my $new = $attr_list{$curr_attr}; if ($curr_attr eq "format" && $params) { $params =~ /^\s*\(\s*(\w+)\s*,\s*(.*)/; - push(@conv_array, "__$1\($2"); + $new = "__$1\($2"; } else { - my $new = $attr_list{$curr_attr}; - push(@conv_array, "$new$params"); + $new = "$new$params"; + } + if (WARN("PREFER_DEFINED_ATTRIBUTE_MACRO", + "Prefer $new over __attribute__(($orig_attr$params))\n" . $herecurr) && + $fix) { + my $remove = "\Q$orig_attr\E" . '\s*' . "\Q$params\E" . '(?:\s*,\s*)?'; + $fixed[$fixlinenr] =~ s/$remove//; + $fixed[$fixlinenr] =~ s/\b__attribute__/$new __attribute__/; + $fixed[$fixlinenr] =~ s/\}\Q$new\E/} $new/; } - } else { - $conv_possible = 0; - last; - } - } - - if (scalar @conv_array > 0 && $conv_possible == 1) { - my $replace = join(' ', @conv_array); - if (WARN("PREFER_DEFINED_ATTRIBUTE_MACRO", - "$replace is preferred over __attribute__(($attr))\n" . $herecurr) && - $fix) { - $fixed[$fixlinenr] =~ s/\b__attribute__\s*\(\s*\(\s*\Q$attr\E\s*\)\s*\)/$replace/; - $fixed[$fixlinenr] =~ s/\}\Q$replace\E/} $replace/; } } - # Check for __attribute__ section, prefer __section - if ($attr =~ /^_*section_*\s*\(\s*("[^"]*")/) { - my $old = substr($attr, $-[1], $+[1] - $-[1]); - my $new = substr($old, 1, -1); - if (WARN("PREFER_DEFINED_ATTRIBUTE_MACRO", - "__section($new) is preferred over __attribute__((section($old)))\n" . $herecurr) && - $fix) { - $fixed[$fixlinenr] =~ s/\b__attribute__\s*\(\s*\(\s*_*section_*\s*\(\s*\Q$old\E\s*\)\s*\)\s*\)/__section($new)/; - } + if (show_type("PREFER_DEFINED_ATTRIBUTE_MACRO") && $fix) { + $fixed[$fixlinenr] =~ s/ __attribute__\s*\(\s*\(\s*\)\s*\)//; } # Check for __attribute__ unused, prefer __always_unused or __maybe_unused
_
Patches currently in -mm which might be from [email protected] are
mm-zswap-make-struct-kernel_param_ops-definitions-const.patch checkpatch-prefer-static-const-declarations.patch checkpatch-allow-fix-removal-of-unnecessary-break-statements.patch checkpatch-update-__attribute__sectionname-quote-removal.patch
Joe Perches
maintainerQuoted 41 lines · On Wed, 2020-10-28 at 14:37 -0700, [email protected] wrote:
The patch titled
Subject: checkpatch: update __attribute__((section("name"))) quote removal has been added to the -mm tree. Its filename is checkpatch-update-__attribute__sectionname-quote-removal.patchThis patch should soon appear at
https://ozlabs.org/~akpm/mmots/broken-out/checkpatch-update-__attribute__sectionname-quote-removal.patch
and later at
https://ozlabs.org/~akpm/mmotm/broken-out/checkpatch-update-__attribute__sectionname-quote-removal.patchBefore you just go and hit "reply", please:
a) Consider who else should be cc'ed
b) Prefer to cc a suitable mailing list as well
c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's*** Remember to use
Documentation/process/submit-checklist.rstwhen testing your code ***The -mm tree is included into linux-next and is updated there every 3-4 working days
------------------------------------------------------
From: Joe Perches <[email protected]>
Subject: checkpatch: update __attribute__((section("name"))) quote removalcommit
33def8498fdd("treewide: Convert macro and uses of__section(foo)to__section("foo")") removed the stringification of the section name and now requires quotes around the named section.Update checkpatch to not remove any quotes when suggesting conversion of __attribute__((section("name"))) to
__section("name")Miscellanea:
o Add section to the hash with
__sectionreplacement
o Remove separate test for __attribute__((section
o Remove the limitation on converting attributes containing only known, possible conversions. Any unknown attribute types are now left as-is and known types are converted and moved before__attribute__and removed from within the __attribute__((list...)).
Quoted 4 lines
Signed-off-by Joe Perches <[email protected]>Cc Dwaipayan Ray <[email protected]>Signed-off-by Andrew Morton <[email protected]>
This is a slightly shorter/better patch as it eliminates the separate test below the possible conversions loop.
Can you substitute it please Andrew?
--- scripts/checkpatch.pl | 47 +++++++++++++++-------------------------------- 1 file changed, 15 insertions(+), 32 deletions(-)
scripts/checkpatch.pl +15 -32
@@ -6216,50 +6216,33 @@ sub process { "noreturn" => "__noreturn", "packed" => "__packed", "pure" => "__pure", + "section" => "__section", "used" => "__used" ); - my @conv_array = (); - my $conv_possible = 1; - while ($attr =~ /\s*(\w+)\s*(${balanced_parens})?/g) { - my $curr_attr = $1; + my $orig_attr = $1; my $params = ''; $params = $2 if defined($2); + my $curr_attr = $orig_attr; $curr_attr =~ s/^[\s_]+|[\s_]+$//g; - if (exists($attr_list{$curr_attr})) { + my $new = $attr_list{$curr_attr}; if ($curr_attr eq "format" && $params) { $params =~ /^\s*\(\s*(\w+)\s*,\s*(.*)/; - push(@conv_array, "__$1\($2"); + $new = "__$1\($2"; } else { - my $new = $attr_list{$curr_attr}; - push(@conv_array, "$new$params"); + $new = "$new$params"; + } + if (WARN("PREFER_DEFINED_ATTRIBUTE_MACRO", + "Prefer $new over __attribute__(($orig_attr$params))\n" . $herecurr) && + $fix) { + my $remove = "\Q$orig_attr\E" . '\s*' . "\Q$params\E" . '(?:\s*,\s*)?'; + $fixed[$fixlinenr] =~ s/$remove//; + $fixed[$fixlinenr] =~ s/\b__attribute__/$new __attribute__/; + $fixed[$fixlinenr] =~ s/\}\Q$new\E/} $new/; + $fixed[$fixlinenr] =~ s/ __attribute__\s*\(\s*\(\s*\)\s*\)//; } - } else { - $conv_possible = 0; - last; - } - } - - if (scalar @conv_array > 0 && $conv_possible == 1) { - my $replace = join(' ', @conv_array); - if (WARN("PREFER_DEFINED_ATTRIBUTE_MACRO", - "$replace is preferred over __attribute__(($attr))\n" . $herecurr) && - $fix) { - $fixed[$fixlinenr] =~ s/\b__attribute__\s*\(\s*\(\s*\Q$attr\E\s*\)\s*\)/$replace/; - $fixed[$fixlinenr] =~ s/\}\Q$replace\E/} $replace/; - } - } - - # Check for __attribute__ section, prefer __section - if ($attr =~ /^_*section_*\s*\(\s*("[^"]*")/) { - my $old = substr($attr, $-[1], $+[1] - $-[1]); - my $new = substr($old, 1, -1); - if (WARN("PREFER_DEFINED_ATTRIBUTE_MACRO", - "__section($new) is preferred over __attribute__((section($old)))\n" . $herecurr) && - $fix) { - $fixed[$fixlinenr] =~ s/\b__attribute__\s*\(\s*\(\s*_*section_*\s*\(\s*\Q$old\E\s*\)\s*\)\s*\)/__section($new)/; } }