[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aJJ0npFx1mwJ-MoV@smile.fi.intel.com>
Date: Wed, 6 Aug 2025 00:16:14 +0300
From: Andy Shevchenko <andriy.shevchenko@...el.com>
To: Greg KH <gregkh@...uxfoundation.org>
Cc: Akhilesh Patil <akhilesh@...iitb.ac.in>, lars@...afoo.de,
Michael.Hennerich@...log.com, jic23@...nel.org,
dlechner@...libre.com, nuno.sa@...log.com, andy@...nel.org,
marcelo.schmitt1@...il.com, gshahrouzi@...il.com,
hridesh699@...il.com, linux-iio@...r.kernel.org,
linux-staging@...ts.linux.dev, linux-kernel@...r.kernel.org,
akhileshpatilvnit@...il.com, skhan@...uxfoundation.org
Subject: Re: [PATCH] staging: iio: ad5933: Fix implicit fall-through in
switch()
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
Powered by blists - more mailing lists