From mboxrd@z Thu Jan 1 00:00:00 1970 From: Takashi Iwai Subject: Re: Removal of assert() in alsa-lib Date: Thu, 02 Dec 2004 13:03:06 +0100 Message-ID: References: Mime-Version: 1.0 (generated by SEMI 1.14.5 - "Awara-Onsen") Content-Type: text/plain; charset=US-ASCII Return-path: In-Reply-To: Sender: alsa-devel-admin@lists.sourceforge.net Errors-To: alsa-devel-admin@lists.sourceforge.net List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , List-Archive: To: Jaroslav Kysela Cc: alsa-devel@lists.sourceforge.net List-Id: alsa-devel@alsa-project.org At Wed, 01 Dec 2004 19:01:37 +0100, I wrote: > > At Wed, 1 Dec 2004 18:51:44 +0100 (CET), > Jaroslav wrote: > > > > On Wed, 1 Dec 2004, Takashi Iwai wrote: > > > > > The patch attached below is a part of changes to replace the excessive > > > assert() with if & error-return. It's for some PCM codes only. > > > Any comments are appreciated. > > > > I think that we should add new macros like SNDERR_VERBOSE etc. to not > > compile error messages to small version of ALSA library (for embedded > > devices etc). Almost all current assert()s meet this rule. > > Or, let the compiler optimize it. > > For example, define like > > #if YES_WE_CHECK_SANITY > #define SND_SANITY_CHECK(x) x > #else > #define SND_SANITY_CHECK(x) 0 > #endif > > so that the code like the following will be removed automatically by > the compiler in the optimized case. > > if (SND_SANITY_CHECK(frames > size)) { > SNDERR("buffer overflow"); > return -EPIPE; > } After rethoght, I think both should be introduced. In many places, the check should be done but the error messages are not needed (always). For example, the check in snd_pcm_mmap_commit() looks mandatory. Such checks should simply return errors without showing error messages unless the debug condition is given. The macro can check it either at the compile time or via an environment variable like LIB_ASOUND_DEBUG=1. Takashi ------------------------------------------------------- SF email is sponsored by - The IT Product Guide Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now. http://productguide.itmanagersjournal.com/