[PATCH] Documentation: Checkpatch.rst: Doc added UNNECESSARY_CAST
Dwaipayan Ray
dwaipayanray1 at gmail.com
Thu Aug 5 13:39:53 UTC 2021
On Thu, Aug 5, 2021 at 4:21 PM Vinesh Raut <vineshraut2017 at gmail.com> wrote:
>
> Documentation was missing for UNNECESSARY_CAST Warning.
> Added it to checkpatch.rst with refers from https://lore.kernel.org
> Also, pointers been mentioned in Documentation
This message isn't particularly useful.
A simple:
Add verbose description for UNNECESSARY_CAST message type.
would have worked.
>
> Suggested-by: Lukas Bulwahn <lukas.bulwahn at gmail.com>
> Signed-off-by: Vinesh Raut <vineshraut2017 at gmail.com>
> ---
> Documentation/dev-tools/checkpatch.rst | 10 ++++++++++
> 1 file changed, 10 insertions(+)
>
> diff --git a/Documentation/dev-tools/checkpatch.rst b/Documentation/dev-tools/checkpatch.rst
> index f0956e9ea2d8..72c2f32b1515 100644
> --- a/Documentation/dev-tools/checkpatch.rst
> +++ b/Documentation/dev-tools/checkpatch.rst
> @@ -268,6 +268,16 @@ Allocation style
>
> See: https://www.kernel.org/doc/html/latest/core-api/memory-allocation.html
>
> + **UNNECESSARY_CASTS**
> + Any alloc functions should not be cast. Because they usually returns the
> + void pointer, which compiler then implicitly picks the type of pointer at
s/returns/return
The sentence sounds weird. Maybe refactor it a bit?
> + run time. Hence, casting is not prefer on any alloc functions. cast may
> + hide bugs if any exist, as compiler supresses the warnings after casting.
Here too. Simpler sentences are preferred.
> +
> + See:
> + http://c-faq.com/malloc/mallocnocast.html
Let's not use this link here. External websites are vulnerable to change.
However lore.kernel.org links are okay.
> + https://lore.kernel.org/lkml/20070808024321.GA6316@redhat.com/
> + https://lore.kernel.org/lkml/a5e60a2b93e10baf84af063f6c8e56402273105d.camel@perches.com/
>
You can enumerate these. See the format followed by other verbose
descriptions.
Dwaipayan.
More information about the Linux-kernel-mentees
mailing list