]> git.alsa-project.org Git - alsa-lib.git/commitdiff
Change assert condition in error message handler
authorTakashi Iwai <tiwai@suse.de>
Wed, 24 Oct 2007 10:53:08 +0000 (12:53 +0200)
committerTakashi Iwai <tiwai@suse.de>
Wed, 24 Oct 2007 10:53:08 +0000 (12:53 +0200)
Activating assert() in the default error message handler isn't always
good for producitve systems.  Make this optional and enable only when
a special configure option is given (i.e. for explicit debugging).

NOTES
configure.in
src/error.c

diff --git a/NOTES b/NOTES
index eb745c6bb9e691ad65f70a0a155f0d4bf4d968a7..b318d1febeb24884ac34d45ee6d2a080667a4770 100644 (file)
--- a/NOTES
+++ b/NOTES
@@ -27,12 +27,15 @@ LIBASOUND_DEBUG is set (to a non-empty value).
 When LIBASOUND_DEBUG=1 is set, the errors in hw_params configuration
 will be dumped to stderr.  Note that this will show even the non-fatal
 errors of plug layer (trial-and-error of parameters).
-When LIBASOUND_DEBUG=2 is set, the default error message handler calls
-assert() to catch with a debugger, in addition to parameter debugging.
 
 This feature is disabled when --with-debug=no is passed to configure,
 i.e. no strict checking is done in alsa-lib.
 
+In addition, when --enable-debug-assert configure option is given and
+when LIBASOUND_DEBUG_ASSERT=1 is set, the default error message
+handler can call assert() to catch with a  debugger.  This feature was
+formerly activated via LIBASOUND_DEBUG=2.
+
 
 Blocking Open Mode
 ==================
index ac728d9a5bded1261bb478221b1df5cce322d00c..8ae68c1645e8732d3a7b8ae75d8a7338d6ac2d05 100644 (file)
@@ -169,6 +169,20 @@ else
   AC_MSG_RESULT(no)
 fi
 
+if test "$debug" = "yes"; then
+  AC_MSG_CHECKING(for debug assert)
+  AC_ARG_ENABLE(debug-assert,
+    AS_HELP_STRING([--enable-debug],
+      [enable assert call at the default error message handler]),
+    debug_assert="$enableval", debug_assert="no")
+  if test "$debug_assert" = "yes"; then
+    AC_MSG_RESULT(yes)
+    AC_DEFINE(ALSA_DEBUG_ASSERT,,[Enable assert at error message handler])
+  else
+    AC_MSG_RESULT(no)
+  fi
+fi
+
 dnl Temporary directory
 AC_MSG_CHECKING(for tmpdir)
 AC_ARG_WITH(tmpdir,
index 9341912b36574032c90793b6dcb683af06d0dfd0..7d5f50993f6f1d4ab78edcca62899edc3ae1d5c9 100644 (file)
@@ -135,8 +135,11 @@ static void snd_err_msg_default(const char *file, int line, const char *function
                fprintf(stderr, ": %s", snd_strerror(err));
        putc('\n', stderr);
        va_end(arg);
-       if (! strcmp(verbose, "assert") || atoi(verbose) > 1)
+#ifdef ALSA_DEBUG_ASSERT
+       verbose = getenv("LIBASOUND_DEBUG_ASSERT");
+       if (verbose && *verbose)
                assert(0);
+#endif
 }
 
 /**