Re: [PATCH v5 0/2] checkpatch: add verbose mode

From: Joe Perches
Date: Sat Feb 20 2021 - 10:19:26 EST


On Sat, 2021-02-20 at 17:32 +0530, Dwaipayan Ray wrote:
> Add a new verbose mode to checkpatch. The verbose test
> descriptions are read from the checkpatch documentation
> file at `Documentation/dev-tools/checkpatch.rst`.
>
> The verbose mode is optional and can be enabled by the
> flag -v or --verbose.
>
> The documentation file is only parsed by checkpatch.pl
> if the verbose mode is enabled. The verbose mode can
> not be used together with the --terse option.
>
> Changes in v5:
> - Change the reference format to use absolute links.
> - Print verbose descriptions only for the first time
>   a message type is encountered.

OK, I think a nice addition would be to add --verbose
text to the --list-types option when used together.

$ ./scripts/checkpatch.pl --list-types --verbose
1 ALLOC_ARRAY_ARGS

The first argument for kcalloc or kmalloc_array should be the
number of elements. sizeof() as the first argument is generally
wrong.

See: https://www.kernel.org/doc/html/latest/core-api/memory-allocation.html

2 ALLOC_SIZEOF_STRUCT

The allocation style is bad. In general for family of
allocation functions using sizeof() to get memory size,
constructs like::

p = alloc(sizeof(struct foo), ...)

should be::

p = alloc(sizeof(*p), ...)

See: https://www.kernel.org/doc/html/latest/process/coding-style.html#allocating-memory

etc...