diff options
author | Oliver Smith <osmith@sysmocom.de> | 2021-07-13 12:18:04 +0200 |
---|---|---|
committer | Oliver Smith <osmith@sysmocom.de> | 2021-07-15 10:21:47 +0200 |
commit | bedf7ed0fb2b002ee032780b4f6f1b86a7a41618 (patch) | |
tree | 1f71e40cd63f7046d911eb971ee4c95962fb7536 /lint | |
parent | 7f0fdda23c7d065e134785f29cb61266f31eaf3a (diff) |
lint: checkpatch.pl: complain about %i in printf
Pau has to remind me often that %d is used instead of %i in Osmocom
trees, so let's automate it.
Complain like this:
src/vty/command.c:3052: WARNING:PRINTF_I_OSMO: Use %d instead of %i
Related: OS#5087
Change-Id: I1a98326f1cbf4d2e0bb948558e5cd1726b0a9868
Diffstat (limited to 'lint')
-rwxr-xr-x | lint/checkpatch/checkpatch.pl | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/lint/checkpatch/checkpatch.pl b/lint/checkpatch/checkpatch.pl index 4da42a9..ca074a7 100755 --- a/lint/checkpatch/checkpatch.pl +++ b/lint/checkpatch/checkpatch.pl @@ -6170,6 +6170,7 @@ sub process { # check for non-standard and hex prefixed decimal printf formats my $show_L = 1; #don't show the same defect twice my $show_Z = 1; + my $show_i = 1; while ($line =~ /(?:^|")([X\t]*)(?:"|$)/g) { my $string = substr($rawline, $-[1], $+[1] - $-[1]); $string =~ s/%%/__/g; @@ -6185,6 +6186,11 @@ sub process { "%Z$1 is non-standard C, use %z$1\n" . $herecurr); $show_Z = 0; } + if ($show_i && $string =~ /%[\*\d\.\$]*i/) { # Osmocom specific + WARN("PRINTF_I_OSMO", + "Use %d instead of %i\n" . $herecurr); + $show_i = 0; + } # check for 0x<decimal> if ($string =~ /0x%[\*\d\.\$\Llzth]*[diou]/) { ERROR("PRINTF_0XDECIMAL", |