All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Documentation: Checkpatch.rst: Doc added UNNECESSARY_CAST
@ 2021-08-05 10:49 Vinesh Raut
  2021-08-05 13:39 ` Dwaipayan Ray
  0 siblings, 1 reply; 2+ messages in thread
From: Vinesh Raut @ 2021-08-05 10:49 UTC (permalink / raw)
  To: lukas.bulwahn; +Cc: dwaipayanray1, linux-kernel-mentees

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

Suggested-by: Lukas Bulwahn <lukas.bulwahn@gmail.com>
Signed-off-by: Vinesh Raut <vineshraut2017@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
+      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.
+
+      See:
+      http://c-faq.com/malloc/mallocnocast.html
+      https://lore.kernel.org/lkml/20070808024321.GA6316@redhat.com/
+      https://lore.kernel.org/lkml/a5e60a2b93e10baf84af063f6c8e56402273105d.camel@perches.com/
 
 API usage
 ---------
-- 
2.30.2

_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] Documentation: Checkpatch.rst: Doc added UNNECESSARY_CAST
  2021-08-05 10:49 [PATCH] Documentation: Checkpatch.rst: Doc added UNNECESSARY_CAST Vinesh Raut
@ 2021-08-05 13:39 ` Dwaipayan Ray
  0 siblings, 0 replies; 2+ messages in thread
From: Dwaipayan Ray @ 2021-08-05 13:39 UTC (permalink / raw)
  To: Vinesh Raut; +Cc: linux-kernel-mentees

On Thu, Aug 5, 2021 at 4:21 PM Vinesh Raut <vineshraut2017@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@gmail.com>
> Signed-off-by: Vinesh Raut <vineshraut2017@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.
_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-08-05 13:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-05 10:49 [PATCH] Documentation: Checkpatch.rst: Doc added UNNECESSARY_CAST Vinesh Raut
2021-08-05 13:39 ` Dwaipayan Ray

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.