From: Andy Shevchenko <andriy.shevchenko@intel.com>
To: Greg KH <gregkh@linuxfoundation.org>
Cc: Akhilesh Patil <akhilesh@ee.iitb.ac.in>,
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: Wed, 6 Aug 2025 00:16:14 +0300 [thread overview]
Message-ID: <aJJ0npFx1mwJ-MoV@smile.fi.intel.com> (raw)
In-Reply-To: <2025072808-evict-snorkel-8998@gregkh>
On Mon, Jul 28, 2025 at 04:23:49PM +0200, Greg KH wrote:
> 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:
...
> > > > + 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.
Hmm... If I read the code correctly it is either already was a dead code before
that patch, or it's still accessible via goto label.
> I'd recommend the "pattern" that the current code is in, it's simpler.
The pattern to return from all switch cases, including default is commonly used
in IIO drivers.
--
With Best Regards,
Andy Shevchenko
next prev parent reply other threads:[~2025-08-05 21:16 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
2025-08-05 21:16 ` Andy Shevchenko [this message]
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=aJJ0npFx1mwJ-MoV@smile.fi.intel.com \
--to=andriy.shevchenko@intel.com \
--cc=Michael.Hennerich@analog.com \
--cc=akhilesh@ee.iitb.ac.in \
--cc=akhileshpatilvnit@gmail.com \
--cc=andy@kernel.org \
--cc=dlechner@baylibre.com \
--cc=gregkh@linuxfoundation.org \
--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