History

checkpatch: add an index variable for fixed lines

Make the fix code a bit easier to read. This should also start to allow an easier mechanism to insert/delete lines eventually too.

Joe Perches committed 12 years ago

Commit 194f66f1 parent c00df191 file · +60 −54Browse files

Showing the changes to scripts/checkpatch.pl (1 of 1 file). Show all

Unified · Split

scripts/checkpatch.pl+60−54
@@ -583,6 +583,8 @@ $chk_signoff = 0 if ($file); · 582 unmodified lines
583583 my @rawlines = ();
584584 my @lines = ();
585585 my @fixed = ();
586+my $fixlinenr = -1;
587+
586588 my $vname;
587589 for my $filename (@ARGV) {
588590 my $FILE;
@@ -611,6 +613,7 @@ for my $filename (@ARGV) { · 22 unmodified lines
611613 @rawlines = ();
612614 @lines = ();
613615 @fixed = ();
616+ $fixlinenr = -1;
614617 }
615618
616619 exit($exit);
@@ -1801,8 +1804,10 @@ sub process { · 1184 unmodified lines
18011804
18021805 $realcnt = 0;
18031806 $linenr = 0;
1807+ $fixlinenr = -1;
18041808 foreach my $line (@lines) {
18051809 $linenr++;
1810+ $fixlinenr++;
18061811 my $sline = $line; #copy of $line
18071812 $sline =~ s/$;/ /g; #with comments as spaces
18081813
@@ -1933,7 +1938,7 @@ sub process { · 124 unmodified lines
19331938 if (WARN("BAD_SIGN_OFF",
19341939 "Do not use whitespace before $ucfirst_sign_off\n" . $herecurr) &&
19351940 $fix) {
1936− $fixed[$linenr - 1] =
1941+ $fixed[$fixlinenr] =
19371942 "$ucfirst_sign_off $email";
19381943 }
19391944 }
@@ -1941,7 +1946,7 @@ sub process { · 1 unmodified line
19411946 if (WARN("BAD_SIGN_OFF",
19421947 "'$ucfirst_sign_off' is the preferred signature form\n" . $herecurr) &&
19431948 $fix) {
1944− $fixed[$linenr - 1] =
1949+ $fixed[$fixlinenr] =
19451950 "$ucfirst_sign_off $email";
19461951 }
19471952
@@ -1950,7 +1955,7 @@ sub process { · 2 unmodified lines
19501955 if (WARN("BAD_SIGN_OFF",
19511956 "Use a single space after $ucfirst_sign_off\n" . $herecurr) &&
19521957 $fix) {
1953− $fixed[$linenr - 1] =
1958+ $fixed[$fixlinenr] =
19541959 "$ucfirst_sign_off $email";
19551960 }
19561961 }
@@ -2089,14 +2094,14 @@ sub process { · 132 unmodified lines
20892094 if (ERROR("DOS_LINE_ENDINGS",
20902095 "DOS line endings\n" . $herevet) &&
20912096 $fix) {
2092− $fixed[$linenr - 1] =~ s/[\s\015]+$//;
2097+ $fixed[$fixlinenr] =~ s/[\s\015]+$//;
20932098 }
20942099 } elsif ($rawline =~ /^\+.*\S\s+$/ || $rawline =~ /^\+\s+$/) {
20952100 my $herevet = "$here\n" . cat_vet($rawline) . "\n";
20962101 if (ERROR("TRAILING_WHITESPACE",
20972102 "trailing whitespace\n" . $herevet) &&
20982103 $fix) {
2099− $fixed[$linenr - 1] =~ s/\s+$//;
2104+ $fixed[$fixlinenr] =~ s/\s+$//;
21002105 }
21012106
21022107 $rpt_cleaners = 1;
@@ -2235,7 +2240,7 @@ sub process { · 132 unmodified lines
22352240 if (WARN("QUOTED_WHITESPACE_BEFORE_NEWLINE",
22362241 "unnecessary whitespace before a quoted newline\n" . $herecurr) &&
22372242 $fix) {
2238− $fixed[$linenr - 1] =~ s/^(\+.*\".*)\s+\\n/$1\\n/;
2243+ $fixed[$fixlinenr] =~ s/^(\+.*\".*)\s+\\n/$1\\n/;
22392244 }
22402245
22412246 }
@@ -2272,7 +2277,7 @@ sub process { · 30 unmodified lines
22722277 if (ERROR("CODE_INDENT",
22732278 "code indent should use tabs where possible\n" . $herevet) &&
22742279 $fix) {
2275− $fixed[$linenr - 1] =~ s/^\+([ \t]+)/"\+" . tabify($1)/e;
2280+ $fixed[$fixlinenr] =~ s/^\+([ \t]+)/"\+" . tabify($1)/e;
22762281 }
22772282 }
22782283
@@ -2282,9 +2287,9 @@ sub process { · 3 unmodified lines
22822287 if (WARN("SPACE_BEFORE_TAB",
22832288 "please, no space before tabs\n" . $herevet) &&
22842289 $fix) {
2285− while ($fixed[$linenr - 1] =~
2290+ while ($fixed[$fixlinenr] =~
22862291 s/(^\+.*) {8,8}+\t/$1\t\t/) {}
2287− while ($fixed[$linenr - 1] =~
2292+ while ($fixed[$fixlinenr] =~
22882293 s/(^\+.*) +\t/$1\t/) {}
22892294 }
22902295 }
@@ -2318,7 +2323,7 @@ sub process { · 27 unmodified lines
23182323 if (CHK("PARENTHESIS_ALIGNMENT",
23192324 "Alignment should match open parenthesis\n" . $hereprev) &&
23202325 $fix && $line =~ /^\+/) {
2321− $fixed[$linenr - 1] =~
2326+ $fixed[$fixlinenr] =~
23222327 s/^\+[ \t]*/\+$goodtabindent/;
23232328 }
23242329 }
@@ -2329,7 +2334,7 @@ sub process { · 4 unmodified lines
23292334 if (CHK("SPACING",
23302335 "No space is necessary after a cast\n" . $herecurr) &&
23312336 $fix) {
2332− $fixed[$linenr - 1] =~
2337+ $fixed[$fixlinenr] =~
23332338 s/(\(\s*$Type\s*\))[ \t]+/$1/;
23342339 }
23352340 }
@@ -2433,7 +2438,7 @@ sub process { · 97 unmodified lines
24332438 if (WARN("LEADING_SPACE",
24342439 "please, no spaces at the start of a line\n" . $herevet) &&
24352440 $fix) {
2436− $fixed[$linenr - 1] =~ s/^\+([ \t]+)/"\+" . tabify($1)/e;
2441+ $fixed[$fixlinenr] =~ s/^\+([ \t]+)/"\+" . tabify($1)/e;
24372442 }
24382443 }
24392444
@@ -2798,10 +2803,10 @@ sub process { · 358 unmodified lines
27982803 if (ERROR("C99_COMMENTS",
27992804 "do not use C99 // comments\n" . $herecurr) &&
28002805 $fix) {
2801− my $line = $fixed[$linenr - 1];
2806+ my $line = $fixed[$fixlinenr];
28022807 if ($line =~ /\/\/(.*)$/) {
28032808 my $comment = trim($1);
2804− $fixed[$linenr - 1] =~ s@\/\/(.*)$@/\* $comment \*/@;
2809+ $fixed[$fixlinenr] =~ s@\/\/(.*)$@/\* $comment \*/@;
28052810 }
28062811 }
28072812 }
@@ -2860,7 +2865,7 @@ sub process { · 52 unmodified lines
28602865 "do not initialise globals to 0 or NULL\n" .
28612866 $herecurr) &&
28622867 $fix) {
2863− $fixed[$linenr - 1] =~ s/($Type\s*$Ident\s*(?:\s+$Modifier))*\s*=\s*(0|NULL|false)\s*;/$1;/;
2868+ $fixed[$fixlinenr] =~ s/($Type\s*$Ident\s*(?:\s+$Modifier))*\s*=\s*(0|NULL|false)\s*;/$1;/;
28642869 }
28652870 }
28662871 # check for static initialisers.
@@ -2869,7 +2874,7 @@ sub process { · 2 unmodified lines
28692874 "do not initialise statics to 0 or NULL\n" .
28702875 $herecurr) &&
28712876 $fix) {
2872− $fixed[$linenr - 1] =~ s/(\bstatic\s.*?)\s*=\s*(0|NULL|false)\s*;/$1;/;
2877+ $fixed[$fixlinenr] =~ s/(\bstatic\s.*?)\s*=\s*(0|NULL|false)\s*;/$1;/;
28732878 }
28742879 }
28752880
@@ -2899,7 +2904,7 @@ sub process { · 23 unmodified lines
28992904 if (ERROR("FUNCTION_WITHOUT_ARGS",
29002905 "Bad function definition - $1() should probably be $1(void)\n" . $herecurr) &&
29012906 $fix) {
2902− $fixed[$linenr - 1] =~ s/(\b($Type)\s+($Ident))\s*\(\s*\)/$2 $3(void)/;
2907+ $fixed[$fixlinenr] =~ s/(\b($Type)\s+($Ident))\s*\(\s*\)/$2 $3(void)/;
29032908 }
29042909 }
29052910
@@ -2908,7 +2913,7 @@ sub process { · 2 unmodified lines
29082913 if (WARN("DEFINE_PCI_DEVICE_TABLE",
29092914 "Prefer struct pci_device_id over deprecated DEFINE_PCI_DEVICE_TABLE\n" . $herecurr) &&
29102915 $fix) {
2911− $fixed[$linenr - 1] =~ s/\b(?:static\s+|)DEFINE_PCI_DEVICE_TABLE\s*\(\s*(\w+)\s*\)\s*=\s*/static const struct pci_device_id $1\[\] = /;
2916+ $fixed[$fixlinenr] =~ s/\b(?:static\s+|)DEFINE_PCI_DEVICE_TABLE\s*\(\s*(\w+)\s*\)\s*=\s*/static const struct pci_device_id $1\[\] = /;
29122917 }
29132918 }
29142919
@@ -2945,7 +2950,7 @@ sub process { · 30 unmodified lines
29452950 my $sub_from = $ident;
29462951 my $sub_to = $ident;
29472952 $sub_to =~ s/\Q$from\E/$to/;
2948− $fixed[$linenr - 1] =~
2953+ $fixed[$fixlinenr] =~
29492954 s@\Q$sub_from\E@$sub_to@;
29502955 }
29512956 }
@@ -2973,7 +2978,7 @@ sub process { · 21 unmodified lines
29732978 my $sub_from = $match;
29742979 my $sub_to = $match;
29752980 $sub_to =~ s/\Q$from\E/$to/;
2976− $fixed[$linenr - 1] =~
2981+ $fixed[$fixlinenr] =~
29772982 s@\Q$sub_from\E@$sub_to@;
29782983 }
29792984 }
@@ -3035,7 +3040,7 @@ sub process { · 55 unmodified lines
30353040 if (WARN("PREFER_PR_LEVEL",
30363041 "Prefer pr_warn(... to pr_warning(...\n" . $herecurr) &&
30373042 $fix) {
3038− $fixed[$linenr - 1] =~
3043+ $fixed[$fixlinenr] =~
30393044 s/\bpr_warning\b/pr_warn/;
30403045 }
30413046 }
@@ -3069,7 +3074,7 @@ sub process { · 27 unmodified lines
30693074 if (WARN("SPACING",
30703075 "missing space after $1 definition\n" . $herecurr) &&
30713076 $fix) {
3072− $fixed[$linenr - 1] =~
3077+ $fixed[$fixlinenr] =~
30733078 s/^(.\s*(?:typedef\s+)?(?:enum|union|struct)(?:\s+$Ident){1,2})([=\{])/$1 $2/;
30743079 }
30753080 }
@@ -3139,7 +3144,7 @@ sub process { · 63 unmodified lines
31393144 }
31403145
31413146 if (show_type("SPACING") && $fix) {
3142− $fixed[$linenr - 1] =~
3147+ $fixed[$fixlinenr] =~
31433148 s/^(.\s*)$Declare\s*\(\s*\*\s*$Ident\s*\)\s*\(/$1 . $declare . $post_declare_space . '(*' . $funcname . ')('/ex;
31443149 }
31453150 }
@@ -3156,7 +3161,7 @@ sub process { · 10 unmodified lines
31563161 if (ERROR("BRACKET_SPACE",
31573162 "space prohibited before open square bracket '['\n" . $herecurr) &&
31583163 $fix) {
3159− $fixed[$linenr - 1] =~
3164+ $fixed[$fixlinenr] =~
31603165 s/^(\+.*?)\s+\[/$1\[/;
31613166 }
31623167 }
@@ -3191,7 +3196,7 @@ sub process { · 28 unmodified lines
31913196 if (WARN("SPACING",
31923197 "space prohibited between function name and open parenthesis '('\n" . $herecurr) &&
31933198 $fix) {
3194− $fixed[$linenr - 1] =~
3199+ $fixed[$fixlinenr] =~
31953200 s/\b$name\s+\(/$name\(/;
31963201 }
31973202 }
@@ -3459,8 +3464,8 @@ sub process { · 261 unmodified lines
34593464 $fixed_line = $fixed_line . $fix_elements[$#elements];
34603465 }
34613466
3462− if ($fix && $line_fixed && $fixed_line ne $fixed[$linenr - 1]) {
3463− $fixed[$linenr - 1] = $fixed_line;
3467+ if ($fix && $line_fixed && $fixed_line ne $fixed[$fixlinenr]) {
3468+ $fixed[$fixlinenr] = $fixed_line;
34643469 }
34653470
34663471
@@ -3471,7 +3476,7 @@ sub process { · 4 unmodified lines
34713476 if (WARN("SPACING",
34723477 "space prohibited before semicolon\n" . $herecurr) &&
34733478 $fix) {
3474− 1 while $fixed[$linenr - 1] =~
3479+ 1 while $fixed[$fixlinenr] =~
34753480 s/^(\+.*\S)\s+;/$1;/;
34763481 }
34773482 }
@@ -3504,7 +3509,7 @@ sub process { · 26 unmodified lines
35043509 if (ERROR("SPACING",
35053510 "space required before the open brace '{'\n" . $herecurr) &&
35063511 $fix) {
3507− $fixed[$linenr - 1] =~ s/^(\+.*(?:do|\))){/$1 {/;
3512+ $fixed[$fixlinenr] =~ s/^(\+.*(?:do|\))){/$1 {/;
35083513 }
35093514 }
35103515
@@ -3522,7 +3527,7 @@ sub process { · 11 unmodified lines
35223527 if (ERROR("SPACING",
35233528 "space required after that close brace '}'\n" . $herecurr) &&
35243529 $fix) {
3525− $fixed[$linenr - 1] =~
3530+ $fixed[$fixlinenr] =~
35263531 s/}((?!(?:,|;|\)))\S)/} $1/;
35273532 }
35283533 }
@@ -3532,7 +3537,7 @@ sub process { · 3 unmodified lines
35323537 if (ERROR("SPACING",
35333538 "space prohibited after that open square bracket '['\n" . $herecurr) &&
35343539 $fix) {
3535− $fixed[$linenr - 1] =~
3540+ $fixed[$fixlinenr] =~
35363541 s/\[\s+/\[/;
35373542 }
35383543 }
@@ -3540,7 +3545,7 @@ sub process { · 1 unmodified line
35403545 if (ERROR("SPACING",
35413546 "space prohibited before that close square bracket ']'\n" . $herecurr) &&
35423547 $fix) {
3543− $fixed[$linenr - 1] =~
3548+ $fixed[$fixlinenr] =~
35443549 s/\s+\]/\]/;
35453550 }
35463551 }
@@ -3551,7 +3556,7 @@ sub process { · 4 unmodified lines
35513556 if (ERROR("SPACING",
35523557 "space prohibited after that open parenthesis '('\n" . $herecurr) &&
35533558 $fix) {
3554− $fixed[$linenr - 1] =~
3559+ $fixed[$fixlinenr] =~
35553560 s/\(\s+/\(/;
35563561 }
35573562 }
@@ -3561,7 +3566,8 @@ sub process { · 3 unmodified lines
35613566 if (ERROR("SPACING",
35623567 "space prohibited before that close parenthesis ')'\n" . $herecurr) &&
35633568 $fix) {
3564− $fixed[$linenr - 1] =~
3569+ print("fixlinenr: <$fixlinenr> fixed[fixlinenr]: <$fixed[$fixlinenr]>\n");
3570+ $fixed[$fixlinenr] =~
35653571 s/\s+\)/\)/;
35663572 }
35673573 }
@@ -3580,7 +3586,7 @@ sub process { · 12 unmodified lines
35803586 if (WARN("INDENTED_LABEL",
35813587 "labels should not be indented\n" . $herecurr) &&
35823588 $fix) {
3583− $fixed[$linenr - 1] =~
3589+ $fixed[$fixlinenr] =~
35843590 s/^(.)\s+/$1/;
35853591 }
35863592 }
@@ -3642,7 +3648,7 @@ sub process { · 55 unmodified lines
36423648 if (ERROR("SPACING",
36433649 "space required before the open parenthesis '('\n" . $herecurr) &&
36443650 $fix) {
3645− $fixed[$linenr - 1] =~
3651+ $fixed[$fixlinenr] =~
36463652 s/\b(if|while|for|switch)\(/$1 \(/;
36473653 }
36483654 }
@@ -3779,7 +3785,7 @@ sub process { · 130 unmodified lines
37793785 "Avoid gcc v4.3+ binary constant extension: <$var>\n" . $herecurr) &&
37803786 $fix) {
37813787 my $hexval = sprintf("0x%x", oct($var));
3782− $fixed[$linenr - 1] =~
3788+ $fixed[$fixlinenr] =~
37833789 s/\b$var\b/$hexval/;
37843790 }
37853791 }
@@ -3815,7 +3821,7 @@ sub process { · 29 unmodified lines
38153821 if (WARN("WHITESPACE_AFTER_LINE_CONTINUATION",
38163822 "Whitespace after \\ makes next lines useless\n" . $herecurr) &&
38173823 $fix) {
3818− $fixed[$linenr - 1] =~ s/\s+$//;
3824+ $fixed[$fixlinenr] =~ s/\s+$//;
38193825 }
38203826 }
38213827
@@ -4170,7 +4176,7 @@ sub process { · 348 unmodified lines
41704176 WARN("MISPLACED_INIT",
41714177 "$attr should be placed after $var\n" . $herecurr))) &&
41724178 $fix) {
4173− $fixed[$linenr - 1] =~ s/(\bstatic\s+(?:const\s+)?)(?:$attr\s+)?($NonptrTypeWithAttr)\s+(?:$attr\s+)?($Ident(?:\[[^]]*\])?)\s*([=;])\s*/"$1" . trim(string_find_replace($2, "\\s*$attr\\s*", " ")) . " " . trim(string_find_replace($3, "\\s*$attr\\s*", "")) . " $attr" . ("$4" eq ";" ? ";" : " = ")/e;
4179+ $fixed[$fixlinenr] =~ s/(\bstatic\s+(?:const\s+)?)(?:$attr\s+)?($NonptrTypeWithAttr)\s+(?:$attr\s+)?($Ident(?:\[[^]]*\])?)\s*([=;])\s*/"$1" . trim(string_find_replace($2, "\\s*$attr\\s*", " ")) . " " . trim(string_find_replace($3, "\\s*$attr\\s*", "")) . " $attr" . ("$4" eq ";" ? ";" : " = ")/e;
41744180 }
41754181 }
41764182 }
@@ -4184,7 +4190,7 @@ sub process { · 7 unmodified lines
41844190 if (ERROR("INIT_ATTRIBUTE",
41854191 "Use of const init definition must use ${attr_prefix}initconst\n" . $herecurr) &&
41864192 $fix) {
4187− $fixed[$linenr - 1] =~
4193+ $fixed[$fixlinenr] =~
41884194 s/$InitAttributeData/${attr_prefix}initconst/;
41894195 }
41904196 }
@@ -4195,12 +4201,12 @@ sub process { · 4 unmodified lines
41954201 if (ERROR("INIT_ATTRIBUTE",
41964202 "Use of $attr requires a separate use of const\n" . $herecurr) &&
41974203 $fix) {
4198− my $lead = $fixed[$linenr - 1] =~
4204+ my $lead = $fixed[$fixlinenr] =~
41994205 /(^\+\s*(?:static\s+))/;
42004206 $lead = rtrim($1);
42014207 $lead = "$lead " if ($lead !~ /^\+$/);
42024208 $lead = "${lead}const ";
4203− $fixed[$linenr - 1] =~ s/(^\+\s*(?:static\s+))/$lead/;
4209+ $fixed[$fixlinenr] =~ s/(^\+\s*(?:static\s+))/$lead/;
42044210 }
42054211 }
42064212
@@ -4213,7 +4219,7 @@ sub process { · 6 unmodified lines
42134219 if (WARN("CONSTANT_CONVERSION",
42144220 "$constant_func should be $func\n" . $herecurr) &&
42154221 $fix) {
4216− $fixed[$linenr - 1] =~ s/\b$constant_func\b/$func/g;
4222+ $fixed[$fixlinenr] =~ s/\b$constant_func\b/$func/g;
42174223 }
42184224 }
42194225
@@ -4263,7 +4269,7 @@ sub process { · 43 unmodified lines
42634269 if (ERROR("SPACING",
42644270 "exactly one space required after that #$1\n" . $herecurr) &&
42654271 $fix) {
4266− $fixed[$linenr - 1] =~
4272+ $fixed[$fixlinenr] =~
42674273 s/^(.\s*\#\s*(ifdef|ifndef|elif))\s{2,}/$1 /;
42684274 }
42694275
@@ -4311,7 +4317,7 @@ sub process { · 41 unmodified lines
43114317 if (WARN("INLINE",
43124318 "plain inline is preferred over $1\n" . $herecurr) &&
43134319 $fix) {
4314− $fixed[$linenr - 1] =~ s/\b(__inline__|__inline)\b/inline/;
4320+ $fixed[$fixlinenr] =~ s/\b(__inline__|__inline)\b/inline/;
43154321
43164322 }
43174323 }
@@ -4336,7 +4342,7 @@ sub process { · 18 unmodified lines
43364342 if (WARN("PREFER_PRINTF",
43374343 "__printf(string-index, first-to-check) is preferred over __attribute__((format(printf, string-index, first-to-check)))\n" . $herecurr) &&
43384344 $fix) {
4339− $fixed[$linenr - 1] =~ s/\b__attribute__\s*\(\s*\(\s*format\s*\(\s*printf\s*,\s*(.*)\)\s*\)\s*\)/"__printf(" . trim($1) . ")"/ex;
4345+ $fixed[$fixlinenr] =~ s/\b__attribute__\s*\(\s*\(\s*format\s*\(\s*printf\s*,\s*(.*)\)\s*\)\s*\)/"__printf(" . trim($1) . ")"/ex;
43404346
43414347 }
43424348 }
@@ -4347,7 +4353,7 @@ sub process { · 4 unmodified lines
43474353 if (WARN("PREFER_SCANF",
43484354 "__scanf(string-index, first-to-check) is preferred over __attribute__((format(scanf, string-index, first-to-check)))\n" . $herecurr) &&
43494355 $fix) {
4350− $fixed[$linenr - 1] =~ s/\b__attribute__\s*\(\s*\(\s*format\s*\(\s*scanf\s*,\s*(.*)\)\s*\)\s*\)/"__scanf(" . trim($1) . ")"/ex;
4356+ $fixed[$fixlinenr] =~ s/\b__attribute__\s*\(\s*\(\s*format\s*\(\s*scanf\s*,\s*(.*)\)\s*\)\s*\)/"__scanf(" . trim($1) . ")"/ex;
43514357 }
43524358 }
43534359
@@ -4362,7 +4368,7 @@ sub process { · 8 unmodified lines
43624368 if (WARN("SIZEOF_PARENTHESIS",
43634369 "sizeof $1 should be sizeof($1)\n" . $herecurr) &&
43644370 $fix) {
4365− $fixed[$linenr - 1] =~ s/\bsizeof\s+((?:\*\s*|)$Lval|$Type(?:\s+$Lval|))/"sizeof(" . trim($1) . ")"/ex;
4371+ $fixed[$fixlinenr] =~ s/\bsizeof\s+((?:\*\s*|)$Lval|$Type(?:\s+$Lval|))/"sizeof(" . trim($1) . ")"/ex;
43664372 }
43674373 }
43684374
@@ -4385,7 +4391,7 @@ sub process { · 16 unmodified lines
43854391 if (WARN("PREFER_SEQ_PUTS",
43864392 "Prefer seq_puts to seq_printf\n" . $herecurr) &&
43874393 $fix) {
4388− $fixed[$linenr - 1] =~ s/\bseq_printf\b/seq_puts/;
4394+ $fixed[$fixlinenr] =~ s/\bseq_printf\b/seq_puts/;
43894395 }
43904396 }
43914397 }
@@ -4414,7 +4420,7 @@ sub process { · 22 unmodified lines
44144420 if (WARN("PREFER_ETHER_ADDR_COPY",
44154421 "Prefer ether_addr_copy() over memcpy() if the Ethernet addresses are __aligned(2)\n" . $herecurr) &&
44164422 $fix) {
4417− $fixed[$linenr - 1] =~ s/\bmemcpy\s*\(\s*$FuncArg\s*,\s*$FuncArg\s*\,\s*ETH_ALEN\s*\)/ether_addr_copy($2, $7)/;
4423+ $fixed[$fixlinenr] =~ s/\bmemcpy\s*\(\s*$FuncArg\s*,\s*$FuncArg\s*\,\s*ETH_ALEN\s*\)/ether_addr_copy($2, $7)/;
44184424 }
44194425 }
44204426
@@ -4502,7 +4508,7 @@ sub process { · 81 unmodified lines
45024508 if (CHK("AVOID_EXTERNS",
45034509 "extern prototypes should be avoided in .h files\n" . $herecurr) &&
45044510 $fix) {
4505− $fixed[$linenr - 1] =~ s/(.*)\bextern\b\s*(.*)/$1$2/;
4511+ $fixed[$fixlinenr] =~ s/(.*)\bextern\b\s*(.*)/$1$2/;
45064512 }
45074513 }
45084514
@@ -4579,7 +4585,7 @@ sub process { · 70 unmodified lines
45794585 if (WARN("ALLOC_WITH_MULTIPLY",
45804586 "Prefer $newfunc over $oldfunc with multiply\n" . $herecurr) &&
45814587 $fix) {
4582− $fixed[$linenr - 1] =~ s/\b($Lval)\s*\=\s*(?:$balanced_parens)?\s*(k[mz]alloc)\s*\(\s*($FuncArg)\s*\*\s*($FuncArg)/$1 . ' = ' . "$newfunc(" . trim($r1) . ', ' . trim($r2)/e;
4588+ $fixed[$fixlinenr] =~ s/\b($Lval)\s*\=\s*(?:$balanced_parens)?\s*(k[mz]alloc)\s*\(\s*($FuncArg)\s*\*\s*($FuncArg)/$1 . ' = ' . "$newfunc(" . trim($r1) . ', ' . trim($r2)/e;
45834589
45844590 }
45854591 }
@@ -4603,7 +4609,7 @@ sub process { · 17 unmodified lines
46034609 if (WARN("ONE_SEMICOLON",
46044610 "Statements terminations use 1 semicolon\n" . $herecurr) &&
46054611 $fix) {
4606− $fixed[$linenr - 1] =~ s/(\s*;\s*){2,}$/;/g;
4612+ $fixed[$fixlinenr] =~ s/(\s*;\s*){2,}$/;/g;
46074613 }
46084614 }
46094615
@@ -4651,7 +4657,7 @@ sub process { · 41 unmodified lines
46514657 if (WARN("USE_FUNC",
46524658 "__func__ should be used instead of gcc specific __FUNCTION__\n" . $herecurr) &&
46534659 $fix) {
4654− $fixed[$linenr - 1] =~ s/\b__FUNCTION__\b/__func__/g;
4660+ $fixed[$fixlinenr] =~ s/\b__FUNCTION__\b/__func__/g;
46554661 }
46564662 }
46574663