On Wed, 2026-10-28 at 08:19 +0000, Dmitry Ilvokhin wrote:
> The kernel provides the __nonnull_args() macro as the preferred form for
> marking pointer arguments as non-NULL. Add a check suggesting the macro
> over the raw __attribute__((nonnull)) spelling, consistent with the
> existing attribute conversion suggestions.
>
> Examples:
>
> WARNING: Prefer __nonnull_args(1, 2) over __attribute__((nonnull(1, 2)))
> #11: FILE: drivers/soc/aspeed/aspeed-lpc-snoop.c:230:
> +__attribute__((nonnull(1, 2)))
>
> WARNING: Prefer __nonnull_args() over __attribute__((nonnull))
> #11: FILE: drivers/soc/aspeed/aspeed-lpc-snoop.c:283:
> +__attribute__((nonnull))
>
> Signed-off-by: Dmitry Ilvokhin <[[email protected]](mailto:[email protected])>
Seems sensible, thanks.
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
[]
> @@ -6856,6 +6856,7 @@ sub process {
> "no_caller_saved_registers" =>
> "__no_caller_saved_registers",
> "noclone" => "__noclone",
> "noinline" => "noinline",
> + "nonnull" =>
> "__nonnull_args",
> "nonstring" =>
> "__nonstring",
> "noreturn" => "__noreturn",
> "packed" => "__packed",
> @@ -6876,6 +6877,8 @@ sub process {
> if ($curr_attr eq "format" && $params) {
> $params =~
> /^\s*\(\s*(\w+)\s*,\s*(.*)/;
> $new = "__$1\($2";
> + } elsif ($curr_attr eq "nonnull" &&
> $params eq "") {
> + $new = "$new()";
> } else {
> $new = "$new$params";
> }
>