From: Takashi Iwai Subject: Re: Kill snd_assert() Date: Mon, 11 Aug 2008 10:58:27 +0200 Message-ID: References: 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 (mx2.suse.de [195.135.220.15]) by alsa0.perex.cz (Postfix) with ESMTP id 051C324405 for ; Mon, 11 Aug 2008 10:58:28 +0200 (CEST) Received: from Relay2.suse.de (relay-ext.suse.de [195.135.221.8]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx2.suse.de (Postfix) with ESMTP id E44E945DD7 for ; Mon, 11 Aug 2008 10:58:27 +0200 (CEST) In-Reply-To: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: alsa-devel-bounces@alsa-project.org Errors-To: alsa-devel-bounces@alsa-project.org To: alsa-devel@alsa-project.org List-Id: alsa-devel@alsa-project.org At Mon, 11 Aug 2008 10:41:37 +0200, I wrote: > > Hi, > > as some people already mentioned, we have a pretty ugly macro, snd_assert(). > Actually, this macro is sometimes useful, but the implementation including > the code flow in arguments is really bad. > > I tried to kill this, either the following way: > > - replace > snd_assert(cond, flow...); > with > if (snd_BUG_ON(!cond)) > flow...; > > - use WARN_ON() if the check is needed essentially regardless of > CONFIG_SND_DBEBUG value > > - remove snd_assert() for obviously unneeded code-paths > > The new snd_BUG_ON() macro takes the condition, and works like > WARN_ON() if CONFIG_SND_DEBUG=y: prints the warning with stack trace, > and returns the evaluated value. When CONFIG_SND_DEBUG=n, the macro > returns always zero, so that the compiler will optimize out the > unreached flows. > > Since snd_BUG_ON() takes the condition of a bug, it's a negative > condition against snd_assert(). It follows BUG_ON() and WARN_ON(), > and easier to understand, IMO. > > > The patches are found on topic/remove-assert branch of my git tree: > > git://git.kernel.org/pub/scm/linux/kernel/tiwai/sound-2.6.git Oops, the correct URL is: git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound-2.6.git Also, the corresponding alsa-driver build tree is found on topic/remove-assert branch of alsa-driver-build.git below: git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/alsa-driver-build.git http://git.kernel.org/?p=linux/kernel/git/tiwai/alsa-driver-build.git;a=shortlog;h=topic/remove-assert Takashi