mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@intel.com>
To: Joshua Crofts <joshua.crofts1@gmail.com>
Cc: Rishab Madhugiri <rishab.madhugiri@gmail.com>,
	jic23@kernel.org, dlechner@baylibre.com, nuno.sa@analog.com,
	andy@kernel.org, linux-iio@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] iio: core: Avoid BUG() on invalid clock types
Date: Mon, 24 Aug 2026 18:25:36 +0300	[thread overview]
Message-ID: <aoxicO-nya_zp9Aj@ashevche-desk.local> (raw)
In-Reply-To: <CALoEA-w8RMArm=STmnaGJJdyHpR7V-58uFz4m9U74aDe+QJe6Q@mail.gmail.com>

On Mon, Aug 24, 2026 at 05:06:24PM +0200, Joshua Crofts wrote:
> On Mon, 24 Aug 2026 at 16:48, Andy Shevchenko
> <andriy.shevchenko@intel.com> wrote:
> > On Mon, Aug 24, 2026 at 12:05:03PM +0200, Joshua Crofts wrote:
> > > On Mon, 24 Aug 2026 12:55:47 +0300
> > > Andy Shevchenko <andriy.shevchenko@intel.com> wrote:
> > > > On Sun, Aug 23, 2026 at 10:25:02PM +0000, Rishab Madhugiri wrote:
> > > > > Replace deprecated use of BUG() in default switch cases of
> > > > > iio_get_time_ns() and current_timestamp_clock_show() with
> > > > > WARN_ONCE() and return correct fallback or error codes.
> > > >
> > > > Why?!
> > >
> > > Because BUG() and BUG_ON() shouldn't be used anymore, no? Linus himself
> > > said that he hates the macros.
> >
> > Why? Please, study the case. As for the above change, there are two questions
> > (at least):
> > - Why BUG() is deprecated? Where is it stated?
> 
> https://docs.kernel.org/process/deprecated.html?hl=en-GB#bug-and-bug-on

Thanks for sharing! So, this is a missing point in the commit message.

> > - What will WARN*() gain us here? (Note some specific kernel command line
> >   parameter that may convert WARN to BUG)
> 
> As Jonathan mentioned earlier, the original BUG() was there to prevent the
> compiler from complaining that all possible values weren't handled. So BUG()
> or WARN*() here is a placeholder. Just removing the BUG() call should be
> valid since it's impossible to hit(?)

Yeah, I was participated in several cases where the compiler made something
strange when BUG() was absent (basically no reachable point which BUG()
represents). Do we have no issues (anymore?) with the compiler with WARN*()?

-- 
With Best Regards,
Andy Shevchenko



  reply	other threads:[~2026-08-24 15:25 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-23 22:25 Rishab Madhugiri
2026-08-23 22:48 ` Jonathan Cameron
2026-08-24  9:55 ` Andy Shevchenko
2026-08-24 10:05   ` Joshua Crofts
2026-08-24 14:48     ` Andy Shevchenko
2026-08-24 15:06       ` Joshua Crofts
2026-08-24 15:25         ` Andy Shevchenko [this message]
2026-08-25 23:48           ` Rishab M

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=aoxicO-nya_zp9Aj@ashevche-desk.local \
    --to=andriy.shevchenko@intel.com \
    --cc=andy@kernel.org \
    --cc=dlechner@baylibre.com \
    --cc=jic23@kernel.org \
    --cc=joshua.crofts1@gmail.com \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nuno.sa@analog.com \
    --cc=rishab.madhugiri@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®