2021-02-20 12:06:06

by Dwaipayan Ray

[permalink] [raw]
Subject: [PATCH v5 0/2] checkpatch: add verbose mode

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.

Changes in v4:
- Change the type description format
- Group the message types by usage
- Make handling of --terse with --verbose simpler

Changes in v3:
- Simplify documentation file parsing in checkpatch
- Document a total of 33 message types for checkpatch

Changes in v2:
- Use .rst Field Lists to specify the type descriptions.
- Add a few more type descriptions to documentation.

Dwaipayan Ray (2):
checkpatch: add verbose mode
docs: add documentation for checkpatch

Documentation/dev-tools/checkpatch.rst | 526 +++++++++++++++++++++++++
Documentation/dev-tools/index.rst | 1 +
scripts/checkpatch.pl | 63 ++-
3 files changed, 587 insertions(+), 3 deletions(-)
create mode 100644 Documentation/dev-tools/checkpatch.rst

--
2.30.0


2021-02-20 15:18:07

by Joe Perches

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

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...