From: Takashi Iwai Subject: Re: Kill snd_assert() Date: Mon, 11 Aug 2008 11:05:45 +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 (ns2.suse.de [195.135.220.15]) by alsa0.perex.cz (Postfix) with ESMTP id E3E0B1037F1 for ; Mon, 11 Aug 2008 11:05:45 +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: Jaroslav Kysela Cc: alsa-devel@alsa-project.org List-Id: alsa-devel@alsa-project.org At Mon, 11 Aug 2008 10:52:23 +0200 (CEST), Jaroslav Kysela wrote: > > On Mon, 11 Aug 2008, Takashi Iwai 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...; > > For my eyes, many uses of snd_assert with direct 'return VALUE' are more > "sexy", easy understandable and smaller. There are pros and cons for this, too. One merit of snd_assert() is its shortness, thus easier to add. But, mining the code flow is dangerous especially if you want to add a paired operation like locks or move the assert to another place. With the explicit code flow, you could follow more easily. > But, as mentioned, when goto is > used to change the code flow, we end up with a compiler warning. It should > be eliminated. Right. > I have no strong objections to accept this change as you proposed. Thank > you for your work. OK, good to hear. thanks, Takashi