Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6e300757 authored by Joe Perches's avatar Joe Perches Committed by Linus Torvalds
Browse files

checkpatch: emit an error on formats with 0x%<decimal>



Using 0x%d is wrong.  Emit a message when it happens.

Miscellanea:

Improve the %Lu warning to match formats like %16Lu.

Signed-off-by: default avatarJoe Perches <joe@perches.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 7bd7e483
Loading
Loading
Loading
Loading
+6 −2
Original line number Original line Diff line number Diff line
@@ -4816,16 +4816,20 @@ sub process {
			     "Consecutive strings are generally better as a single string\n" . $herecurr);
			     "Consecutive strings are generally better as a single string\n" . $herecurr);
		}
		}


# check for %L{u,d,i} in strings
# check for %L{u,d,i} and 0x%[udi] in strings
		my $string;
		my $string;
		while ($line =~ /(?:^|")([X\t]*)(?:"|$)/g) {
		while ($line =~ /(?:^|")([X\t]*)(?:"|$)/g) {
			$string = substr($rawline, $-[1], $+[1] - $-[1]);
			$string = substr($rawline, $-[1], $+[1] - $-[1]);
			$string =~ s/%%/__/g;
			$string =~ s/%%/__/g;
			if ($string =~ /(?<!%)%L[udi]/) {
			if ($string =~ /(?<!%)%[\*\d\.\$]*L[udi]/) {
				WARN("PRINTF_L",
				WARN("PRINTF_L",
				     "\%Ld/%Lu are not-standard C, use %lld/%llu\n" . $herecurr);
				     "\%Ld/%Lu are not-standard C, use %lld/%llu\n" . $herecurr);
				last;
				last;
			}
			}
			if ($string =~ /0x%[\*\d\.\$\Llzth]*[udi]/) {
				ERROR("PRINTF_0xDECIMAL",
				      "Prefixing 0x with decimal output is defective\n" . $herecurr);
			}
		}
		}


# check for line continuations in quoted strings with odd counts of "
# check for line continuations in quoted strings with odd counts of "