Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758093Ab3CFOFA (ORCPT ); Wed, 6 Mar 2013 09:05:00 -0500 Received: from cantor2.suse.de ([195.135.220.15]:41850 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757175Ab3CFOE5 (ORCPT ); Wed, 6 Mar 2013 09:04:57 -0500 Date: Wed, 06 Mar 2013 15:04:56 +0100 Message-ID: From: Takashi Iwai To: David Henningsson Cc: Christine Spang , Sasha Levin , alsa-devel@alsa-project.org, Jamie Iles , linux-kernel@vger.kernel.org Subject: Re: [alsa-devel] [PATCH] Make snd_BUG_ON() always evaluate and return the conditional expression. In-Reply-To: <51374968.4070805@canonical.com> References: <1362434579-7733-1-git-send-email-christine.spang@oracle.com> <51365862.9050401@oracle.com> <51374968.4070805@canonical.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL/10.8 Emacs/24.2 (x86_64-suse-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1780 Lines: 44 At Wed, 06 Mar 2013 14:49:28 +0100, David Henningsson wrote: > > 2013-03-05 21:41, Christine Spang skrev: > > On 03/05/2013 04:05 AM, Takashi Iwai wrote: > >> At Mon, 4 Mar 2013 17:02:59 -0500, > >> Christine Spang wrote: > >>> Having snd_BUG_ON() only evaluate its conditional when CONFIG_SND_DEBUG > >>> is set leads to frequent bugs, since other similar macros in the kernel > >>> have different behavior. Let's make snd_BUG_ON() act like those macros > >>> so it will stop being accidentally misused. > >>> > >>> Signed-off-by: Christine Spang > >> Sounds reasonable. The dependency on CONFIG_SND_DEBUG was for > >> allowing more optimization, but since we use this for more places than > >> expected, this change would be safer indeed. > >> > >> If no one has objection, I'll apply it for 3.10 kernel. > > If snd_BUG_ON now works like WARN_ON rather than BUG_ON (at least it > does with this change, if I understand things right), No, snd_BUG_ON() has always been equivalent with WARN_ON() when CONFIG_SND_DEBUG is set. But it's empty when CONFIG_SND_DEBUG=n (i.e. the conditional is ignored). Christine's patch changes the behavior in only the latter case. It enables the conditional but doesn't involve WARN_ON(), so the check is done silently. > maybe we should > rename it to snd_WARN_ON for consistency? Maybe. As an additional note, BUG_ON() should be almost never used in the normal driver codes. If you find BUG_ON() in a driver code, doubt it twice whether it's right. Takashi -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/