From: "Fabio M. De Francesco" <fmdefrancesco@gmail.com>
To: Julia Lawall <julia.lawall@inria.fr>, Joe Perches <joe@perches.com>
Cc: sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com,
gregkh@linuxfoundation.org, outreachy-kernel@googlegroups.com,
mike.rapoport@gmail.com, kushalkothari2850@gmail.com,
Kushal Kothari <kushalkothari285@gmail.com>
Subject: Re: [Outreachy kernel] [PATCH] staging: sm750fb: make pointers in array const
Date: Mon, 18 Oct 2021 21:01:00 +0200 [thread overview]
Message-ID: <1888062.QCrhZ3JNfs@localhost.localdomain> (raw)
In-Reply-To: <40e4c388a2be3a6fcb99600a8f6897d9542f9344.camel@perches.com>
On Monday, October 18, 2021 8:52:41 PM CEST Joe Perches wrote:
> On Mon, 2021-10-18 at 20:34 +0200, Fabio M. De Francesco wrote:
> > On Monday, October 18, 2021 8:22:23 PM CEST Joe Perches wrote:
> > > On Mon, 2021-10-18 at 19:18 +0200, Fabio M. De Francesco wrote:
> > > > On Monday, October 18, 2021 7:01:42 PM CEST Julia Lawall wrote:
> > > > >
> > > > > On Mon, 18 Oct 2021, Fabio M. De Francesco wrote:
> > > > >
> > > > > > On Monday, October 18, 2021 6:44:31 PM CEST Kushal Kothari wrote:
> > > > > > > Change the parameters of functions from const char *g_fbmode[]
to
> > > > > > > const char * const g_fbmode[]. This additional const is needed
to
> > > > > > > allow us to fix checkpatch warning, as well as being good
> > > > > > > programming practice.
> > > > > > >
> > > > > > > For the checkpatch warnings, if we have a set of command line
> > > > > > > args that we want to check defined as:
> > > > > > > static const char * g_fbmode[] = {NULL, NULL};
> > > > > > >
> > > > > > > checkpatch will complain:
> > > > > > > WARNING: static const char * array should probably be static
> > > > const
> > > > > > char * const
> > > > > > >
> > > > > > > Signed-off-by: Kushal Kothari <kushalkothari285@gmail.com>
> > > > > > > ---
> > > > > > >
> > > > > > > [...]
> > > > > > >
> > > > > > > -static const char *g_fbmode[] = {NULL, NULL};
> > > > > > > +static const char * const g_fbmode[] = {NULL, NULL};
> > > > > >
> > > > > > You have introduced a logical change (g_fbmode[] entries cannot
be
> > > > assigned
> > > > > > any more) and a build error (because there is code somewhere that
> > assigns
> > > > > > values to those slots).
> > > > >
> > > > > I wonder if this warning makes much sense when the array elements
are
> > > > > NULL. I don't know if checkpatch could easily detect that.
> > >
> > > No, it couldn't really. It's a line by line parser and most frequently
> > > these are on separate lines.
> >
> > Sorry but I don't get it. For sure I'm missing something...
> >
> > I guess that checkpatch.pl warned Kushal because it detected that the
array
> > of pointers was assigned with something and so it output that "static
const
> > char * array should probably be static const".
> >
> > What I cannot understand is why it _can_ detect that the array is
assigned
> > with some values but it _cannot_ check that those values are 'NULL' and
so
> > avoid to warn.
>
> It's a simple rule.
>
> char *foo[] = { should probably be const char * const foo[] = {
>
> There are exceptions and that's why the message output is a warning
> and the text includes the word "probably" and not "must".
>
> It's up to the reader to determine if the warning is valid or not.
>
> That's true for _every_ output error, warning or strict message
> checkpatch emits.
>
> checkpatch is a stupid brainless script doing trivial pattern matches.
>
> People should _use_ their brains and not blindly trust and follow
> brainless scripts.
>
> And especially, everyone should compile and test changes _before_
> submitting patches.
>
> It doesn't matter if a tool that produces a warning is checkpatch,
> sparse, coccinelle or a compiler.
>
> Validate and test _before_ submitting a patch.
>
Yes, after some more thinking about this matter I agree with you :)
This is why I wrote another message for explaining my new POV some minutes
ago.
Thanks,
Fabio
next prev parent reply other threads:[~2021-10-18 19:01 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-18 16:44 [PATCH] staging: sm750fb: make pointers in array const Kushal Kothari
2021-10-18 16:54 ` [Outreachy kernel] " Fabio M. De Francesco
2021-10-18 17:01 ` Julia Lawall
2021-10-18 17:18 ` Fabio M. De Francesco
2021-10-18 18:22 ` Joe Perches
2021-10-18 18:34 ` Fabio M. De Francesco
2021-10-18 18:43 ` Julia Lawall
2021-10-18 18:56 ` kushal kothari
2021-10-18 19:53 ` Alison Schofield
2021-10-18 18:56 ` Fabio M. De Francesco
2021-10-18 18:52 ` Joe Perches
2021-10-18 19:01 ` Fabio M. De Francesco [this message]
2021-10-18 18:18 ` Fabio M. De Francesco
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1888062.QCrhZ3JNfs@localhost.localdomain \
--to=fmdefrancesco@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=joe@perches.com \
--cc=julia.lawall@inria.fr \
--cc=kushalkothari2850@gmail.com \
--cc=kushalkothari285@gmail.com \
--cc=mike.rapoport@gmail.com \
--cc=outreachy-kernel@googlegroups.com \
--cc=sudipm.mukherjee@gmail.com \
--cc=teddy.wang@siliconmotion.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.