[alsa-devel] [PATCH 21/31] ASoC: dapm: Use WARN_ON() instead of BUG_ON()

Takashi Iwai tiwai at suse.de
Wed Nov 6 12:33:14 CET 2013

At Wed, 6 Nov 2013 11:15:29 +0000,
Mark Brown wrote:
> [1  <text/plain; us-ascii (7bit)>]
> On Wed, Nov 06, 2013 at 12:05:00PM +0100, Takashi Iwai wrote:
> > BUG_ON() is rather useless for debugging as it leads to panic().
> > Use WARN_ON() and handle the error cases accordingly.
> Please fix the comment about BUG_ON() being useless; it does exactly
> what it's supposed to do.

Well,  I can correct the word "useless" with "stupid" in the comment,
as BUG_ON() is the most stupid idea to do at such a point.  soc-dapm.c
is the common code that can be executed from any others. How you can
know that the machine *must* be killed suddenly at this point?  If you
didn't attach the console beforehand, you can't get even any debug

Using BUG() and BUG_ON() in buggy points without any really serious
damage (like heavy memory corruption or data corruption) has to be
avoided.  Linus stated this in the past, too.  (I have no pointer
now, unfortunately.)

> > Also another WARN_ON() check is added in dapm_seq_run_coalesced()
> > since now the show goes on after the first WARN_ON().
> Why?
> >  	list_for_each_entry(w, pending, power_list) {
> > +		if (WARN_ON(reg != w->reg))
> > +			continue;
> >  		dapm_seq_check_event(card, w, SND_SOC_DAPM_POST_PMU);
> >  		dapm_seq_check_event(card, w, SND_SOC_DAPM_POST_PMD);
> >  	}
> We're not using reg here...

Because you must not issue *_POST_* events without *_PRE_* events.
*_PRE_* are skipped for these entries in the previous WARN_ON()


More information about the Alsa-devel mailing list