Commit Graph

14 Commits

Author SHA1 Message Date
Xining Xu b1be5844c1 scripts: checkpatch: check unused parameters for function-like macro
If function-like macros do not utilize a parameter, it might result in a
build warning.  In our coding style guidelines, we advocate for utilizing
static inline functions to replace such macros.  This patch verifies
compliance with the new rule.

For a macro such as the one below,

 #define test(a) do { } while (0)

The test result is as follows.

 WARNING: Argument 'a' is not used in function-like macro
 #21: FILE: mm/init-mm.c:20:
 +#define test(a) do { } while (0)

 total: 0 errors, 1 warnings, 8 lines checked

Link: https://lkml.kernel.org/r/20240507032757.146386-3-21cnbao@gmail.com
Signed-off-by: Xining Xu <mac.xxn@outlook.com>
Tested-by: Barry Song <v-songbaohua@oppo.com>
Signed-off-by: Barry Song <v-songbaohua@oppo.com>
Acked-by: Joe Perches <joe@perches.com>
Cc: Chris Zankel <chris@zankel.net>
Cc: Huacai Chen <chenhuacai@loongson.cn>
Cc: Herbert Xu <herbert@gondor.apana.org.au>
Cc: Guenter Roeck <linux@roeck-us.net>
Cc: Stephen Rothwell <sfr@canb.auug.org.au>
Cc: Mark Brown <broonie@kernel.org>
Cc: Andy Whitcroft <apw@canonical.com>
Cc: Dwaipayan Ray <dwaipayanray1@gmail.com>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Lukas Bulwahn <lukas.bulwahn@gmail.com>
Cc: Max Filippov <jcmvbkbc@gmail.com>
Cc: Jeff Johnson <quic_jjohnson@quicinc.com>
Cc: Charlemagne Lasse <charlemagnelasse@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
2024-05-11 15:51:44 -07:00
Thorsten Blum 6fca09b64f docs: dev-tools: checkpatch.rst: Fix grammar
- s/exists/exist/
- s/maybe/may be/

Signed-off-by: Thorsten Blum <thorsten.blum@toblux.com>
Reviewed-by: Randy Dunlap <rdunlap@infradead.org>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Link: https://lore.kernel.org/r/20240208152039.65293-1-thorsten.blum@toblux.com
2024-02-12 16:42:13 -07:00
Niklas Söderlund bd17e036b4 checkpatch: warn for non-standard fixes tag style
Add a warning for fixes tags that does not follow community conventions.

Link: https://lkml.kernel.org/r/20220914100255.1048460-1-niklas.soderlund@corigine.com
Signed-off-by: Niklas Söderlund <niklas.soderlund@corigine.com>
Reviewed-by: Simon Horman <simon.horman@corigine.com>
Reviewed-by: Louis Peens <louis.peens@corigine.com>
Reviewed-by: Philippe Schenker <philippe.schenker@toradex.com>
Acked-by: Dwaipayan Ray <dwaipayanray1@gmail.com>
Reviewed-by: Lukas Bulwahn <lukas.bulwahn@gmail.com>
Acked-by: Lukas Bulwahn <lukas.bulwahn@gmail.com>
Acked-by: Joe Perches <joe@perches.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
2022-10-03 14:21:44 -07:00
Jonathan Corbet b19511926c Revert "docs: checkpatch: add UNNECESSARY/UNSPECIFIED_INT and UNNECESSARY_ELSE"
This reverts commit cbb817fc2e.

Late-arriving nacks make it clear that I applied this one too soon.

Link: https://lore.kernel.org/lkml/CAKXUXMzEFQd1JJhx4ZbBQiuSB7Fk3bd7dwJYmPOvEtMqZopxpg@mail.gmail.com/
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
2021-10-04 17:13:53 -06:00
Utkarsh Verma 250a0a5ba9 docs: checkpatch: add multiline, do/while, and multiple-assignment messages
Added and documented 3 new message types:
- MULTILINE_DEREFERENCE
- SINGLE_STATEMENT_DO_WHILE_MACRO
- MULTIPLE_ASSIGNMENTS

Signed-off-by: Utkarsh Verma <utkarshverma294@gmail.com>
Link: https://lore.kernel.org/r/20210925163852.12096-1-utkarshverma294@gmail.com
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
2021-09-27 11:42:45 -06:00
Utkarsh Verma cbb817fc2e docs: checkpatch: add UNNECESSARY/UNSPECIFIED_INT and UNNECESSARY_ELSE
Added and documented 3 new message types:
- UNNECESSARY_INT
- UNSPECIFIED_INT
- UNNECESSARY_ELSE

Signed-off-by: Utkarsh Verma <utkarshverma294@gmail.com>
Link: https://lore.kernel.org/r/20210925201746.15917-1-utkarshverma294@gmail.com
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
2021-09-27 11:39:16 -06:00
Utkarsh Verma 3454cd5616 Documentation: checkpatch: Add SYMBOLIC_PERMS message
Add a new message type SYMBOLIC_PERMS under the 'Permissions'
subsection. Octal permission bits are easier to read and understand
instead of their symbolic macro names.

Suggested-by: Lukas Bulwahn <lukas.bulwahn@gmail.com>
Signed-off-by: Utkarsh Verma <utkarshverma294@gmail.com>
Reviewed-by: Lukas Bulwahn <lukas.bulwahn@gmail.com>
Acked-by: Dwaipayan Ray <dwaipayanray1@gmail.com>
Link: https://lore.kernel.org/r/20210904082330.14864-1-utkarshverma294@gmail.com
[jc: Tweaked wording as suggested by Dwaipayan Ray]
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
2021-09-14 15:09:24 -06:00
Utkarsh Verma 29bd0cace2 Documentation: checkpatch: Add TRAILING_SEMICOLON message
Add a new message type TRAILING_SEMICOLON for the macro definitions
that conclude with a semicolon.

Suggested-by: Lukas Bulwahn <lukas.bulwahn@gmail.com>
Signed-off-by: Utkarsh Verma <utkarshverma294@gmail.com>
Link: https://lore.kernel.org/r/20210904074201.13532-1-utkarshverma294@gmail.com
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
2021-09-14 15:07:49 -06:00
Utkarsh Verma d9548979f7 Documentation: checkpatch: Add SPLIT_STRING message
Add a new message type SPLIT_STRING under the 'Indentation and Line
Breaks' subsection. Checkpatch documentation for the splitting of
quoted strings that appear in userspace, across multiple lines.

Suggested-by: Lukas Bulwahn <lukas.bulwahn@gmail.com>
Signed-off-by: Utkarsh Verma <utkarshverma294@gmail.com>
Link: https://lore.kernel.org/r/20210904073621.12987-1-utkarshverma294@gmail.com
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
2021-09-14 15:07:26 -06:00
Dwaipayan Ray 91a1265cac docs: checkpatch: Document and segregate more checkpatch message types
Add and document more checkpatch message types. About 50% of all
message types are documented now.

In addition to this:

- Create a new subsection 'Indentation and Line Breaks'.
- Rename subsection 'Comment style' to simply 'Comments'.
- Refactor some of the existing types to appropriate subsections.

Reviewed-by: Lukas Bulwahn <lukas.bulwahn@gmail.com>
Tested-by: Lukas Bulwahn <lukas.bulwahn@gmail.com>
Signed-off-by: Dwaipayan Ray <dwaipayanray1@gmail.com>
Link: https://lore.kernel.org/r/20210614141132.6881-1-dwaipayanray1@gmail.com
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
2021-06-14 15:37:12 -06:00
Andrew Jeffery 0e7c52da1a Documentation: checkpatch: Tweak BIT() macro include
While include/linux/bitops.h brings in the BIT() macro, it was moved to
include/linux/bits.h in commit 8bd9cb51da ("locking/atomics, asm-generic:
Move some macros from <linux/bitops.h> to a new <linux/bits.h> file").

Since that commit BIT() has moved again into include/vdso/bits.h via
commit 3945ff37d2 ("linux/bits.h: Extract common header for vDSO").

I think the move to the vDSO header can be considered an implementation
detail, so for now update the checkpatch documentation to recommend use
of include/linux/bits.h.

Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
Acked-by: Jiri Slaby <jirislaby@kernel.org>
Acked-by: Lukas Bulwahn <lukas.bulwahn@gmail.com>
Acked-by: Dwaipayan Ray <dwaipayanray1@gmail.com>
Cc: Jiri Slaby <jirislaby@kernel.org>
Link: https://lore.kernel.org/r/20210520093949.511471-1-andrew@aj.id.au
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
2021-05-20 14:27:30 -06:00
Dwaipayan Ray 76001b8bbf docs: Add more message type documentations for checkpatch
- Document a couple of more checkpatch message types.
- Add a blank line before all `See:` lines to improve the
  rst output.
- Create a new subsection `Permissions` and move a few types
  to it.

Signed-off-by: Dwaipayan Ray <dwaipayanray1@gmail.com>
Acked-by: Lukas Bulwahn <lukas.bulwahn@gmail.com>
Link: https://lore.kernel.org/r/20210515132348.19082-1-dwaipayanray1@gmail.com
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
2021-05-20 14:12:44 -06:00
Dwaipayan Ray 3337c3a152 docs: document all error message types in checkpatch
All the error message types now have a verbose description.

Also there are two new groups of message types:

- Macros, Attributes and Symbols
- Functions and Variables

Rearrange the message types to fit these new groups as needed.

Signed-off-by: Dwaipayan Ray <dwaipayanray1@gmail.com>
Reviewed-by: Lukas Bulwahn <lukas.bulwahn@gmail.com>
Link: https://lore.kernel.org/r/20210322082139.33822-1-dwaipayanray1@gmail.com
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
2021-03-25 11:47:42 -06:00
Dwaipayan Ray 2eecbab864 docs: add documentation for checkpatch
Add documentation for kernel script checkpatch.pl.
This documentation is also parsed by checkpatch to
enable a verbose mode.

The checkpatch message types are grouped by usage. Under
each group the types are described briefly. 34 of such
types are documented.

Signed-off-by: Dwaipayan Ray <dwaipayanray1@gmail.com>
Link: https://lore.kernel.org/r/20210226093827.12700-2-dwaipayanray1@gmail.com
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
2021-03-06 17:36:51 -07:00