From: Takashi Iwai Subject: Re: [PATCH 21/31] ASoC: dapm: Use WARN_ON() instead of BUG_ON() Date: Wed, 06 Nov 2013 12:33:14 +0100 Message-ID: References: <1383673218-18405-1-git-send-email-tiwai@suse.de> <1383673218-18405-22-git-send-email-tiwai@suse.de> <20131106102431.GM11602@sirena.org.uk> <20131106111529.GH11602@sirena.org.uk> Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mx2.suse.de (cantor2.suse.de [195.135.220.15]) by alsa0.perex.cz (Postfix) with ESMTP id CB9DE2616F4 for ; Wed, 6 Nov 2013 12:33:14 +0100 (CET) In-Reply-To: <20131106111529.GH11602@sirena.org.uk> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org To: Mark Brown Cc: alsa-devel@alsa-project.org, Liam Girdwood List-Id: alsa-devel@alsa-project.org At Wed, 6 Nov 2013 11:15:29 +0000, Mark Brown wrote: > > [1 ] > 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 logs. 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() checks. Takashi