]> git.alsa-project.org Git - alsa-lib.git/commitdiff
error: fix the "return old snd_lib_error_set_handler() behaviour"
authorJaroslav Kysela <perex@perex.cz>
Thu, 8 Jan 2026 12:19:34 +0000 (13:19 +0100)
committerJaroslav Kysela <perex@perex.cz>
Thu, 8 Jan 2026 12:19:45 +0000 (13:19 +0100)
The variable arguments must be handled differently. Add a conversion
routine which use the original argument call convention.

Fixes: f55eece8 ("error: return old snd_lib_error_set_handler() behaviour")
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
src/error.c

index ae54b598e297bcc62a1b72262998fee15c209748..df8ba522a86436ba852d3e293b391900737c527b 100644 (file)
@@ -293,6 +293,8 @@ int snd_lib_log_filter(int prio, int interface, const char *configstr)
        return prio <= (int)level;
 }
 
+static void snd_lib_error_vdefault(const char *file, int line, const char *function, int errcode, const char *fmt, va_list arg);
+
 /**
  * \brief The default log handler function.
  * \param prio Priority value (SND_LOG_*).
@@ -322,7 +324,7 @@ static void snd_lib_vlog_default(int prio, int interface, const char *file, int
        }
        if (snd_lib_error != snd_lib_error_default) {
                if (prio == SND_LOG_ERROR)
-                       snd_lib_error(file, line, function, errcode, fmt, arg);
+                       snd_lib_error_vdefault(file, line, function, errcode, fmt, arg);
                /* ignore other priorities - restore old behaviour */
                return;
        }
@@ -452,6 +454,25 @@ static void snd_lib_error_default(const char *file, int line, const char *functi
        va_end(arg);
 }
 
+/**
+ * \brief The default error handler function.
+ * \param file The filename where the error was hit.
+ * \param line The line number.
+ * \param function The function name.
+ * \param errcode The error code.
+ * \param fmt The message (including the format characters).
+ * \param arg Optional arguments.
+ * \deprecated Since 1.2.15
+ *
+ * Use snd_lib_vlog handler to print error message for anonymous interface.
+ */
+static void snd_lib_error_vdefault(const char *file, int line, const char *function, int errcode, const char *fmt, va_list arg)
+{
+       char msg[512];
+       vsnprintf(msg, sizeof(msg), fmt, arg);
+       snd_lib_error(file, line, function, errcode, "%s", msg);
+}
+
 /**
  * \ingroup Error
  * \deprecated Since 1.2.15