All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] Documentation: checkpatch: add UNNECESSARY_CASTS message.
@ 2021-08-06 15:18 Vinesh Raut
  2021-08-06 17:31 ` Vinesh Vilas Raut
  2021-08-06 20:06 ` Dwaipayan Ray
  0 siblings, 2 replies; 4+ messages in thread
From: Vinesh Raut @ 2021-08-06 15:18 UTC (permalink / raw)
  To: lukas.bulwahn; +Cc: dwaipayanray1, linux-kernel-mentees

Add verbose description for UNNECESSARY_CASTS message type.

Suggested-by: Lukas Bulwahn <lukas.bulwahn@gmail.com>
Signed-off-by: Vinesh Raut <vineshraut2017@gmail.com>
---
 Documentation/dev-tools/checkpatch.rst | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/Documentation/dev-tools/checkpatch.rst b/Documentation/dev-tools/checkpatch.rst
index f0956e9ea2d8..9cb6b9059fc6 100644
--- a/Documentation/dev-tools/checkpatch.rst
+++ b/Documentation/dev-tools/checkpatch.rst
@@ -268,6 +268,15 @@ Allocation style
 
     See: https://www.kernel.org/doc/html/latest/core-api/memory-allocation.html
 
+   **UNNECESSAR_CASTS**
+   Cast should not be done to any alloc functions.
+   Appropriate type of pointer is pick by compiler at run time
+   Cast may hide bugs, as compiler suppress the warning after cast.
+
+   See:
+   1] https://lore.kernel.org/lkml/20070808024321.GA6316@redhat.com/
+   2] 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] 4+ messages in thread

* Re: [PATCH v2] Documentation: checkpatch: add UNNECESSARY_CASTS message.
  2021-08-06 15:18 [PATCH v2] Documentation: checkpatch: add UNNECESSARY_CASTS message Vinesh Raut
@ 2021-08-06 17:31 ` Vinesh Vilas Raut
  2021-08-06 20:06 ` Dwaipayan Ray
  1 sibling, 0 replies; 4+ messages in thread
From: Vinesh Vilas Raut @ 2021-08-06 17:31 UTC (permalink / raw)
  To: Lukas Bulwahn; +Cc: Dwaipayan Ray, linux-kernel-mentees

On Fri, Aug 6, 2021 at 8:49 PM Vinesh Raut <vineshraut2017@gmail.com> wrote:

>
>      See: https://www.kernel.org/doc/html/latest/core-api/memory-allocation.html
>
> +   **UNNECESSAR_CASTS**
spelling mistake
**UNNECESSARY_CASTS**
_______________________________________________
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] 4+ messages in thread

* Re: [PATCH v2] Documentation: checkpatch: add UNNECESSARY_CASTS message.
  2021-08-06 15:18 [PATCH v2] Documentation: checkpatch: add UNNECESSARY_CASTS message Vinesh Raut
  2021-08-06 17:31 ` Vinesh Vilas Raut
@ 2021-08-06 20:06 ` Dwaipayan Ray
  2021-08-09 13:32   ` Vinesh Vilas Raut
  1 sibling, 1 reply; 4+ messages in thread
From: Dwaipayan Ray @ 2021-08-06 20:06 UTC (permalink / raw)
  To: Vinesh Raut; +Cc: linux-kernel-mentees

On Fri, Aug 6, 2021 at 8:49 PM Vinesh Raut <vineshraut2017@gmail.com> wrote:
>
> Add verbose description for UNNECESSARY_CASTS message type.
>
> Suggested-by: Lukas Bulwahn <lukas.bulwahn@gmail.com>
> Signed-off-by: Vinesh Raut <vineshraut2017@gmail.com>
> ---
>  Documentation/dev-tools/checkpatch.rst | 9 +++++++++
>  1 file changed, 9 insertions(+)
>
> diff --git a/Documentation/dev-tools/checkpatch.rst b/Documentation/dev-tools/checkpatch.rst
> index f0956e9ea2d8..9cb6b9059fc6 100644
> --- a/Documentation/dev-tools/checkpatch.rst
> +++ b/Documentation/dev-tools/checkpatch.rst
> @@ -268,6 +268,15 @@ Allocation style
>
>      See: https://www.kernel.org/doc/html/latest/core-api/memory-allocation.html
>
> +   **UNNECESSAR_CASTS**
> +   Cast should not be done to any alloc functions.
> +   Appropriate type of pointer is pick by compiler at run time
s/run time/runtime

> +   Cast may hide bugs, as compiler suppress the warning after cast.

The question which arises here is what kind of bug is suppressed.
Maybe follow http://c-faq.com/malloc/mallocnocast.html as checkpatch
says to write up a paragraph on why it is bad.

> +
> +   See:
> +   1] https://lore.kernel.org/lkml/20070808024321.GA6316@redhat.com/
> +   2] https://lore.kernel.org/lkml/a5e60a2b93e10baf84af063f6c8e56402273105d.camel@perches.com/

These links are just patches that introduced the test. There is not much
information about "why" they were introduced.

Other than that change the enumeration type to be
uniform with the rest of the documentation maybe?
The thing followed till now is:

See:
  1. link_1
  2. link_2

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] 4+ messages in thread

* Re: [PATCH v2] Documentation: checkpatch: add UNNECESSARY_CASTS message.
  2021-08-06 20:06 ` Dwaipayan Ray
@ 2021-08-09 13:32   ` Vinesh Vilas Raut
  0 siblings, 0 replies; 4+ messages in thread
From: Vinesh Vilas Raut @ 2021-08-09 13:32 UTC (permalink / raw)
  To: Dwaipayan Ray; +Cc: linux-kernel-mentees

On Sat, Aug 7, 2021 at 1:36 AM Dwaipayan Ray <dwaipayanray1@gmail.com> wrote:
>
> On Fri, Aug 6, 2021 at 8:49 PM Vinesh Raut <vineshraut2017@gmail.com> wrote:
> >
> > Add verbose description for UNNECESSARY_CASTS message type.
> >
> > Suggested-by: Lukas Bulwahn <lukas.bulwahn@gmail.com>
> > Signed-off-by: Vinesh Raut <vineshraut2017@gmail.com>
> > ---
> >  Documentation/dev-tools/checkpatch.rst | 9 +++++++++
> >  1 file changed, 9 insertions(+)
> >
> > diff --git a/Documentation/dev-tools/checkpatch.rst b/Documentation/dev-tools/checkpatch.rst
> > index f0956e9ea2d8..9cb6b9059fc6 100644
> > --- a/Documentation/dev-tools/checkpatch.rst
> > +++ b/Documentation/dev-tools/checkpatch.rst
> > @@ -268,6 +268,15 @@ Allocation style
> >
> >      See: https://www.kernel.org/doc/html/latest/core-api/memory-allocation.html
> >
> > +   **UNNECESSAR_CASTS**

+   **UNNECESSARY_CASTS**

> > +   Cast should not be done to any alloc functions.
> > +   Appropriate type of pointer is pick by compiler at run time

+   Appropriate type of pointer is pick by compiler at runtime

> s/run time/runtime
>
> > +   Cast may hide bugs, as compiler suppresses the warning after cast.


+   If a pointer is cast (wrongly), bugs like memory corruption,
segmentation faults can occur.
+   Also, It can affect functionality of the program.


>
> The question which arises here is what kind of bug is suppressed.
> Maybe follow http://c-faq.com/malloc/mallocnocast.html as checkpatch
> says to write up a paragraph on why it is bad.
>
> > +
> > +   See:
> > +   1] https://lore.kernel.org/lkml/20070808024321.GA6316@redhat.com/
> > +   2] https://lore.kernel.org/lkml/a5e60a2b93e10baf84af063f6c8e56402273105d.camel@perches.com/
>
> These links are just patches that introduced the test. There is not much
> information about "why" they were introduced.

Should I remove it?
And I didnt found any discussion on LKML regarding  UNNECESSARY_CASTS issue,
other than this patches.

>
> Other than that change the enumeration type to be
> uniform with the rest of the documentation maybe?
> The thing followed till now is:
>
> See:
>   1. link_1
>   2. link_2

+   See:
+   1. https://lore.kernel.org/lkml/20070808024321.GA6316@redhat.com/
+   2. https://lore.kernel.org/lkml/a5e60a2b93e10baf84af063f6c8e56402273105d.camel@perches.com/

>
> 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] 4+ messages in thread

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

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-06 15:18 [PATCH v2] Documentation: checkpatch: add UNNECESSARY_CASTS message Vinesh Raut
2021-08-06 17:31 ` Vinesh Vilas Raut
2021-08-06 20:06 ` Dwaipayan Ray
2021-08-09 13:32   ` Vinesh Vilas Raut

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.