The patch titled From: Joe Perches <joe@xxxxxxxxxxx> has been added to the -mm tree. Its filename is checkpatch-warn-on-unnecessary-int-declarations.patch This patch should soon appear at http://ozlabs.org/~akpm/mmots/broken-out/checkpatch-warn-on-unnecessary-int-declarations.patch and later at http://ozlabs.org/~akpm/mmotm/broken-out/checkpatch-warn-on-unnecessary-int-declarations.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 <joe@xxxxxxxxxxx> Subject: checkpatch: warn on unnecessary int declarations On Sun, 2018-08-05 at 08:52 -0700, Linus Torvalds wrote: > "long unsigned int" isn't _technically_ wrong. But we normally > call that type "unsigned long". So add a checkpatch test for it. Link: http://lkml.kernel.org/r/7bbd97dc0a1e5896a0251fada7bb68bb33643f77.camel@xxxxxxxxxxx Signed-off-by: Joe Perches <joe@xxxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- diff -puN scripts/checkpatch.pl~checkpatch-warn-on-unnecessary-int-declarations scripts/checkpatch.pl --- a/scripts/checkpatch.pl~checkpatch-warn-on-unnecessary-int-declarations +++ a/scripts/checkpatch.pl @@ -3829,6 +3829,26 @@ sub process { "type '$tmp' should be specified in [[un]signed] [short|int|long|long long] order\n" . $herecurr); } +# check for unnecessary <signed> int declarations of short/long/long long + while ($sline =~ m{\b($TypeMisordered(\s*\*)*|$C90_int_types)\b}g) { + my $type = trim($1); + next if ($type !~ /\bint\b/); + next if ($type !~ /\b(?:short|long\s+long|long)\b/); + my $new_type = $type; + $new_type =~ s/\b\s*int\s*\b/ /; + $new_type =~ s/\b\s*(?:un)?signed\b\s*/ /; + $new_type =~ s/^const\s+//; + $new_type = "unsigned $new_type" if ($type =~ /\bunsigned\b/); + $new_type = "const $new_type" if ($type =~ /^const\b/); + $new_type =~ s/\s+/ /g; + $new_type = trim($new_type); + if (WARN("UNNECESSARY_INT", + "Prefer '$new_type' over '$type' as the int is unnecessary\n" . $herecurr) && + $fix) { + $fixed[$fixlinenr] =~ s/\b\Q$type\E\b/$new_type/; + } + } + # check for static const char * arrays. if ($line =~ /\bstatic\s+const\s+char\s*\*\s*(\w+)\s*\[\s*\]\s*=\s*/) { WARN("STATIC_CONST_CHAR_ARRAY", _ Patches currently in -mm which might be from joe@xxxxxxxxxxx are spdxcheck-work-with-current-head-licenses-directory.patch checkpatch-add-a-strict-test-for-structs-with-bool-member-definitions.patch checkpatch-add-fix-for-concatenated_string-and-string_fragments.patch checkpatch-improve-runtime-execution-speed-a-little.patch checkpatch-fix-macro-argument-reuse-test.patch checkpatch-validate-spdx-license-with-spdxcheckpy.patch checkpatch-fix-krealloc-reuse-test.patch checkpatch-check-for-functions-with-passed-by-value-structs-or-unions.patch checkpatch-warn-when-a-patch-doesnt-have-a-description.patch checkpatch-fix-spdx-license-check-with-root=path.patch checkpatch-warn-on-unnecessary-int-declarations.patch -- To unsubscribe from this list: send the line "unsubscribe mm-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html