Linux kernel staging patches
 help / color / mirror / Atom feed
From: Greg KH <gregkh@linuxfoundation.org>
To: Akhilesh Patil <akhilesh@ee.iitb.ac.in>
Cc: lars@metafoo.de, Michael.Hennerich@analog.com, jic23@kernel.org,
	dlechner@baylibre.com, nuno.sa@analog.com, andy@kernel.org,
	marcelo.schmitt1@gmail.com, gshahrouzi@gmail.com,
	hridesh699@gmail.com, linux-iio@vger.kernel.org,
	linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org,
	akhileshpatilvnit@gmail.com, skhan@linuxfoundation.org
Subject: Re: [PATCH] staging: iio: ad5933: Fix implicit fall-through in switch()
Date: Mon, 28 Jul 2025 16:23:49 +0200	[thread overview]
Message-ID: <2025072808-evict-snorkel-8998@gregkh> (raw)
In-Reply-To: <aIeDDsRurrgXqRQn@bhairav-test.ee.iitb.ac.in>

On Mon, Jul 28, 2025 at 07:32:54PM +0530, Akhilesh Patil wrote:
> On Mon, Jul 28, 2025 at 12:39:21PM +0200, Greg KH wrote:
> > On Mon, Jul 28, 2025 at 03:29:28PM +0530, Akhilesh Patil wrote:
> > > Add default case in switch() codeblock in ad5933_read_raw().
> > > Convert implicit error return due to switch fallthrough to explicit return
> > > to make intent clear. Follow kernel switch fall-thorugh guidelines at
> > > Documentation/process/deprecated.rst
> > > 
> > > Signed-off-by: Akhilesh Patil <akhilesh@ee.iitb.ac.in>
> > > ---
> > > Checked build for 6.16.0 kernel with ad5933
> > > ---
> > >  drivers/staging/iio/impedance-analyzer/ad5933.c | 3 ++-
> > >  1 file changed, 2 insertions(+), 1 deletion(-)
> > > 
> > > diff --git a/drivers/staging/iio/impedance-analyzer/ad5933.c b/drivers/staging/iio/impedance-analyzer/ad5933.c
> > > index 85a4223295cd..6547a259b8a0 100644
> > > --- a/drivers/staging/iio/impedance-analyzer/ad5933.c
> > > +++ b/drivers/staging/iio/impedance-analyzer/ad5933.c
> > > @@ -533,9 +533,10 @@ static int ad5933_read_raw(struct iio_dev *indio_dev,
> > >  		*val = 1000;
> > >  		*val2 = 5;
> > >  		return IIO_VAL_FRACTIONAL_LOG2;
> > > +	default:
> > > +		return -EINVAL;
> > 
> > What tool is requiring this to be added?  It's totally redundant and
> > needs to have the tool fixed instead.
> 
> This patch is not inspired by any tool as such.
> I observed this code pattern while manually reading the staging area iio
> code. From my eyes, there is implicit intention to return from switch block if
> no match is found which can be improved in readibility by explicit
> default block returning error.
> I agree this is redundant and will not have any functional impact.
> However, imo - this can help support kernel wide efforts to
> clarify switch() blocks.
> 
> The motivation for this patch is from a035d552 which talks about
> eleminating ambiguity by clearly defining swich() case blocks.

Yes, but the code right after this does the "default return", so that is
now dead code.

I'd recommend the "pattern" that the current code is in, it's simpler.

thanks,

greg k-h

  reply	other threads:[~2025-07-28 14:23 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-28  9:59 [PATCH] staging: iio: ad5933: Fix implicit fall-through in switch() Akhilesh Patil
2025-07-28 10:39 ` Greg KH
2025-07-28 14:02   ` Akhilesh Patil
2025-07-28 14:23     ` Greg KH [this message]
2025-08-05 21:16       ` Andy Shevchenko
2025-08-08  9:57         ` Akhilesh Patil
2025-08-08 12:47           ` Andy Shevchenko

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=2025072808-evict-snorkel-8998@gregkh \
    --to=gregkh@linuxfoundation.org \
    --cc=Michael.Hennerich@analog.com \
    --cc=akhilesh@ee.iitb.ac.in \
    --cc=akhileshpatilvnit@gmail.com \
    --cc=andy@kernel.org \
    --cc=dlechner@baylibre.com \
    --cc=gshahrouzi@gmail.com \
    --cc=hridesh699@gmail.com \
    --cc=jic23@kernel.org \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-staging@lists.linux.dev \
    --cc=marcelo.schmitt1@gmail.com \
    --cc=nuno.sa@analog.com \
    --cc=skhan@linuxfoundation.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox