X-Git-Url: https://sigrok.org/gitweb/?p=libsigrokdecode.git;a=blobdiff_plain;f=exception.c;h=96546f7d5537797bf45049159be70787e68aeaf5;hp=0c248e169e4c4b45502a8d781df86b532e47801c;hb=4916b17368e8ed06f4bfd045052ab0f891c33954;hpb=aafeeaea1731a1e0c8322527ccb0e4cdcc5ffb01 diff --git a/exception.c b/exception.c index 0c248e1..96546f7 100644 --- a/exception.c +++ b/exception.c @@ -1,5 +1,5 @@ /* - * This file is part of the sigrok project. + * This file is part of the libsigrokdecode project. * * Copyright (C) 2012 Bert Vermeulen * @@ -17,13 +17,14 @@ * along with this program. If not, see . */ -#include "sigrokdecode.h" /* First, so we avoid a _POSIX_C_SOURCE warning. */ -#include "sigrokdecode-internal.h" +#include "libsigrokdecode-internal.h" /* First, so we avoid a _POSIX_C_SOURCE warning. */ +#include "libsigrokdecode.h" #include "config.h" #include #include #include /* Python header not pulled in by default. */ +/** @private */ SRD_PRIV void srd_exception_catch(const char *format, ...) { PyObject *etype, *evalue, *etb, *py_str; @@ -45,24 +46,23 @@ SRD_PRIV void srd_exception_catch(const char *format, ...) return; } - msg = g_string_sized_new(128); - va_start(args, format); - g_string_vprintf(msg, format, args); - va_end(args); - - /* Can be NULL. */ + /* Send the exception error message(s) to srd_err(). */ if (evalue) ename = (char *)Py_TYPE(evalue)->tp_name; else + /* Can be NULL. */ ename = "(unknown exception)"; - /* Send the exception error message(s) to srd_err(). */ - py_str_as_str(py_str, &str); + msg = g_string_sized_new(128); g_string_append(msg, ename); g_string_append(msg, ": "); + va_start(args, format); + g_string_append_vprintf(msg, format, args); + va_end(args); + py_str_as_str(py_str, &str); g_string_append(msg, str); Py_DecRef(py_str); - srd_err(msg->str); + srd_err("%s", msg->str); /* Send a more precise error location to srd_dbg(), if we have it. */ if (etb && etb != Py_None) { @@ -75,7 +75,7 @@ SRD_PRIV void srd_exception_catch(const char *format, ...) py_str_as_str(py_str, &tracestr); Py_DecRef(py_str); g_string_printf(msg, "%s in %s: %s", ename, tracestr, str); - srd_dbg(msg->str); + srd_dbg("%s", msg->str); g_free(tracestr); } g_free(str);