diff --git a/src/assuan-support.c b/src/assuan-support.c index 09db3295..0ddf29b6 100644 --- a/src/assuan-support.c +++ b/src/assuan-support.c @@ -54,7 +54,7 @@ _gpgme_assuan_log_cb (assuan_context_t ctx, void *hook, if (msg == NULL) return 1; - _gpgme_debug (DEBUG_ASSUAN, -1, NULL, NULL, NULL, "%s", msg); + _gpgme_debug (NULL, DEBUG_ASSUAN, -1, NULL, NULL, NULL, "%s", msg); return 0; } diff --git a/src/data-compat.c b/src/data-compat.c index 64ed2d28..4960bf49 100644 --- a/src/data-compat.c +++ b/src/data-compat.c @@ -160,7 +160,7 @@ gpgme_error_to_errno (gpgme_error_t err) break; } } - TRACE (DEBUG_DATA, "gpgme:gpgme_error_to_errno", 0, + TRACE (DEBUG_DATA, "gpgme:gpgme_error_to_errno", NULL, "mapping %s <%s> to: %s", gpgme_strerror (err), gpgme_strsource (err), strerror (res)); gpg_err_set_errno (res); diff --git a/src/data-fd.c b/src/data-fd.c index 5c68130f..4bc8f610 100644 --- a/src/data-fd.c +++ b/src/data-fd.c @@ -75,7 +75,7 @@ gpgme_error_t gpgme_data_new_from_fd (gpgme_data_t *r_dh, int fd) { gpgme_error_t err; - TRACE_BEG (DEBUG_DATA, "gpgme_data_new_from_fd", r_dh, "fd=0x%x", fd); + TRACE_BEG (DEBUG_DATA, "gpgme_data_new_from_fd", r_dh, "fd=%d", fd); err = _gpgme_data_new (r_dh, &fd_cbs); if (err) diff --git a/src/data-mem.c b/src/data-mem.c index f51d2fd7..539b4536 100644 --- a/src/data-mem.c +++ b/src/data-mem.c @@ -296,7 +296,7 @@ gpgme_data_release_and_get_mem (gpgme_data_t dh, size_t *r_len) void gpgme_free (void *buffer) { - TRACE (DEBUG_DATA, "gpgme_free", buffer, ""); + TRACE (DEBUG_DATA, "gpgme_free", NULL, "p=%p", buffer); if (buffer) free (buffer); diff --git a/src/data.c b/src/data.c index 44ef2d3d..70595907 100644 --- a/src/data.c +++ b/src/data.c @@ -574,7 +574,7 @@ _gpgme_data_inbound_handler (void *opaque, int fd) char *bufp = buffer; gpgme_ssize_t buflen; TRACE_BEG (DEBUG_CTX, "_gpgme_data_inbound_handler", dh, - "fd=0x%x", fd); + "fd=%d", fd); buflen = _gpgme_io_read (fd, buffer, BUFFER_SIZE); if (buflen < 0) @@ -605,7 +605,7 @@ _gpgme_data_outbound_handler (void *opaque, int fd) gpgme_data_t dh = (gpgme_data_t) data->handler_value; gpgme_ssize_t nwritten; TRACE_BEG (DEBUG_CTX, "_gpgme_data_outbound_handler", dh, - "fd=0x%x", fd); + "fd=%d", fd); if (!dh->pending_len) { diff --git a/src/debug.c b/src/debug.c index 69e02b6f..0ddb1539 100644 --- a/src/debug.c +++ b/src/debug.c @@ -196,12 +196,12 @@ debug_init (void) if (debug_level > 0) { - _gpgme_debug (DEBUG_INIT, -1, NULL, NULL, NULL, + _gpgme_debug (NULL, DEBUG_INIT, -1, NULL, NULL, NULL, "gpgme_debug: level=%d\n", debug_level); #ifdef HAVE_W32_SYSTEM { const char *name = _gpgme_get_inst_dir (); - _gpgme_debug (DEBUG_INIT, -1, NULL, NULL, NULL, + _gpgme_debug (NULL, DEBUG_INIT, -1, NULL, NULL, NULL, "gpgme_debug: gpgme='%s'\n", name? name: "?"); } #endif @@ -231,6 +231,10 @@ _gpgme_debug_subsystem_init (void) * 2 = debug a function (used by macro TRACE_LOG) * 3 = leave a function (used by macro TRACE_SUC) * + * If LINE is not NULL the output will be stored in that variabale but + * without a LF. _gpgme_debug_add can be used to add more and + * _gpgme_debug_end to finally output it. + * * Returns: 0 * * Note that we always return 0 because the old TRACE macro evaluated @@ -240,7 +244,8 @@ _gpgme_debug_subsystem_init (void) * value from the TRACE macros are actually used somewhere. */ int -_gpgme_debug (int level, int mode, const char *func, const char *tagname, +_gpgme_debug (void **line, int level, int mode, + const char *func, const char *tagname, const char *tagvalue, const char *format, ...) { va_list arg_ptr; @@ -248,7 +253,7 @@ _gpgme_debug (int level, int mode, const char *func, const char *tagname, int need_lf; int indent; char *prefix, *stdinfo, *userinfo; - int no_stdinfo = 0; + const char *modestr; if (debug_level < level) return 0; @@ -275,31 +280,21 @@ _gpgme_debug (int level, int mode, const char *func, const char *tagname, switch (mode) { - case -1: /* Do nothing. */ - stdinfo = NULL; - no_stdinfo = 1; - break; - case 0: - stdinfo = gpgrt_bsprintf ("%s: call: %s=%p ", func, tagname, tagvalue); - break; - case 1: - stdinfo = gpgrt_bsprintf ("%s: enter: %s=%p ", func, tagname, tagvalue); - break; - case 2: - stdinfo = gpgrt_bsprintf ("%s: check: %s=%p ", func, tagname, tagvalue); - break; - case 3: - if (tagname) - stdinfo = gpgrt_bsprintf ("%s: leave: %s=%p ", func, tagname, tagvalue); - else - stdinfo = gpgrt_bsprintf ("%s: leave: ", func); - break; - default: - stdinfo = gpgrt_bsprintf ("%s: ?(mode=%d): %s=%p ", - func, mode, tagname, tagvalue); - break; + case -1: modestr = NULL; break; /* Do nothing. */ + case 0: modestr = "call"; break; + case 1: modestr = "enter"; break; + case 2: modestr = "check"; break; + case 3: modestr = "leave"; break; + default: modestr = "mode?"; break; } + if (!modestr) + stdinfo = NULL; + else if (tagname && strcmp (tagname, XSTRINGIFY (NULL))) + stdinfo = gpgrt_bsprintf ("%s: %s: %s=%p ", func,modestr,tagname,tagvalue); + else + stdinfo = gpgrt_bsprintf ("%s: %s: ", func, modestr); + userinfo = gpgrt_vbsprintf (format, arg_ptr); va_end (arg_ptr); @@ -310,13 +305,22 @@ _gpgme_debug (int level, int mode, const char *func, const char *tagname, else need_lf = 0; - - fprintf (errfp, "%s%s%s%s", - prefix? prefix : "GPGME out-of-core ", - no_stdinfo? "" : stdinfo? stdinfo : "out-of-core ", - userinfo? userinfo : "out-of-core", - need_lf? "\n":""); - fflush (errfp); + if (line) + *line = gpgrt_bsprintf ("%s%s%s", + prefix? prefix : "GPGME out-of-core ", + !modestr? "" : stdinfo? stdinfo : + (!format || !*format)? "" :"out-of-core ", + userinfo? userinfo : "out-of-core"); + else + { + fprintf (errfp, "%s%s%s%s", + prefix? prefix : "GPGME out-of-core ", + !modestr? "" : stdinfo? stdinfo : + (!format || !*format)? "" :"out-of-core ", + userinfo? userinfo : "out-of-core", + need_lf? "\n":""); + fflush (errfp); + } gpgrt_free (userinfo); gpgrt_free (stdinfo); @@ -326,29 +330,6 @@ _gpgme_debug (int level, int mode, const char *func, const char *tagname, } -/* Start a new debug line in *LINE, logged at level LEVEL or higher, - and starting with the formatted string FORMAT. */ -void -_gpgme_debug_begin (void **line, int level, const char *format, ...) -{ - va_list arg_ptr; - int res; - - if (debug_level < level) - { - /* Disable logging of this line. */ - *line = NULL; - return; - } - - va_start (arg_ptr, format); - res = gpgrt_vasprintf ((char **) line, format, arg_ptr); - va_end (arg_ptr); - if (res < 0) - *line = NULL; -} - - /* Add the formatted string FORMAT to the debug line *LINE. */ void _gpgme_debug_add (void **line, const char *format, ...) @@ -389,7 +370,7 @@ _gpgme_debug_end (void **line) /* The smallest possible level is 1, so force logging here by using that. */ - _gpgme_debug (1, -1, NULL, NULL, NULL, "%s", (char*)*line); + _gpgme_debug (NULL, 1, -1, NULL, NULL, NULL, "%s", (char*)*line); gpgrt_free (*line); *line = NULL; } @@ -438,6 +419,6 @@ _gpgme_debug_buffer (int lvl, const char *const fmt, *(strp++) = ' '; *(strp2) = '\0'; - _gpgme_debug (lvl, -1, NULL, NULL, NULL, fmt, func, str); + _gpgme_debug (NULL, lvl, -1, NULL, NULL, NULL, fmt, func, str); } } diff --git a/src/debug.h b/src/debug.h index 7ef8cf23..08d063c6 100644 --- a/src/debug.h +++ b/src/debug.h @@ -68,15 +68,11 @@ int _gpgme_debug_set_debug_envvar (const char *value); void _gpgme_debug_subsystem_init (void); /* Log the formatted string FORMAT at debug level LEVEL or higher. */ -int _gpgme_debug (int level, int mode, +int _gpgme_debug (void **line, int level, int mode, const char *func, const char *tagname, const char *tagvalue, - const char *format, ...) GPGRT_ATTR_PRINTF(6,7); + const char *format, ...) GPGRT_ATTR_PRINTF(7,8); -/* Start a new debug line in *LINE, logged at level LEVEL or higher, - and starting with the formatted string FORMAT. */ -void _gpgme_debug_begin (void **helper, int level, const char *format, ...); - /* Add the formatted string FORMAT to the debug line *LINE. */ void _gpgme_debug_add (void **helper, const char *format, ...); @@ -94,7 +90,7 @@ int _gpgme_debug_frame_end (void); static inline gpgme_error_t _gpgme_trace_gpgme_error (gpgme_error_t err, const char *file, int line) { - _gpgme_debug (DEBUG_ENGINE, -1, NULL, NULL, NULL, + _gpgme_debug (NULL, DEBUG_ENGINE, -1, NULL, NULL, NULL, "%s:%d: returning error: %s\n", _gpgme_debug_srcname (file), line, gpgme_strerror (err)); return err; @@ -116,13 +112,13 @@ _gpgme_trace_gpgme_error (gpgme_error_t err, const char *file, int line) /* Note: We can't protect this with a do-while block. */ #define TRACE_BEG(lvl, name, tag, ...) \ _TRACE (lvl, name, tag); \ - _gpgme_debug (_gpgme_trace_level, 1, \ + _gpgme_debug (NULL, _gpgme_trace_level, 1, \ _gpgme_trace_func, _gpgme_trace_tagname, _gpgme_trace_tag, \ __VA_ARGS__) #define TRACE(lvl, name, tag, ...) do { \ _gpgme_debug_frame_begin (); \ - _gpgme_debug (lvl, 0, name, STRINGIFY (tag), (void *)(uintptr_t)tag, \ + _gpgme_debug (NULL, lvl, 0, name, STRINGIFY (tag), (void *)(uintptr_t)tag, \ __VA_ARGS__); \ _gpgme_debug_frame_end (); \ } while (0) @@ -135,9 +131,9 @@ static inline gpg_error_t _trace_err (gpg_error_t err, int lvl, const char *func, int line) { if (!err) - _gpgme_debug (lvl, 3, func, NULL, NULL, ""); + _gpgme_debug (NULL, lvl, 3, func, NULL, NULL, ""); else - _gpgme_debug (lvl, -1, NULL, NULL, NULL, + _gpgme_debug (NULL, lvl, -1, NULL, NULL, NULL, "%s:%d: error: %s <%s>\n", func, line, gpgme_strerror (err), gpgme_strsource (err)); _gpgme_debug_frame_end (); @@ -151,9 +147,9 @@ static inline int _trace_sysres (int res, int lvl, const char *func, int line) { if (res >= 0) - _gpgme_debug (lvl, 3, func, NULL, NULL, "result=%d", res); + _gpgme_debug (NULL, lvl, 3, func, NULL, NULL, "result=%d", res); else - _gpgme_debug (lvl, -1, NULL, NULL, NULL, + _gpgme_debug (NULL, lvl, -1, NULL, NULL, NULL, "%s:%d: error: %s (%d)\n", func, line, strerror (res), res); _gpgme_debug_frame_end (); @@ -167,9 +163,9 @@ static inline int _trace_syserr (int rc, int lvl, const char *func, int line) { if (!rc) - _gpgme_debug (lvl, 3, func, NULL, NULL, "result=0"); + _gpgme_debug (NULL, lvl, 3, func, NULL, NULL, "result=0"); else - _gpgme_debug (lvl, -1, NULL, NULL, NULL, + _gpgme_debug (NULL, lvl, -1, NULL, NULL, NULL, "%s:%d: error: %s (%d)\n", func, line, strerror (rc), rc); _gpgme_debug_frame_end (); @@ -177,13 +173,13 @@ _trace_syserr (int rc, int lvl, const char *func, int line) } #define TRACE_SUC(...) do { \ - _gpgme_debug (_gpgme_trace_level, 3, _gpgme_trace_func, NULL, NULL, \ + _gpgme_debug (NULL, _gpgme_trace_level, 3, _gpgme_trace_func, NULL, NULL, \ __VA_ARGS__); \ _gpgme_debug_frame_end (); \ } while (0) #define TRACE_LOG(...) do { \ - _gpgme_debug (_gpgme_trace_level, 2, \ + _gpgme_debug (NULL, _gpgme_trace_level, 2, \ _gpgme_trace_func, _gpgme_trace_tagname, _gpgme_trace_tag, \ __VA_ARGS__); \ } while (0) @@ -198,10 +194,9 @@ _trace_syserr (int rc, int lvl, const char *func, int line) _gpgme_trace_func, buf, len); \ } while (0) -#define TRACE_SEQ(hlp,fmt) do { \ - _gpgme_debug_begin (&(hlp), _gpgme_trace_level, \ - "%s: check: %s=%p, " fmt, _gpgme_trace_func, \ - _gpgme_trace_tagname, _gpgme_trace_tag); \ +#define TRACE_SEQ(hlp,...) do { \ + _gpgme_debug (&(hlp), _gpgme_trace_level, 2, _gpgme_trace_func, \ + _gpgme_trace_tagname, _gpgme_trace_tag, __VA_ARGS__); \ } while (0) #define TRACE_ADD0(hlp,fmt) \ diff --git a/src/dirinfo.c b/src/dirinfo.c index 5db61093..c4f0e4a0 100644 --- a/src/dirinfo.c +++ b/src/dirinfo.c @@ -262,13 +262,13 @@ get_gpgconf_item (int what) pgmname = dirinfo.disable_gpgconf? NULL : _gpgme_get_gpgconf_path (); if (pgmname && _gpgme_access (pgmname, F_OK)) { - _gpgme_debug (DEBUG_INIT, -1, NULL, NULL, NULL, + _gpgme_debug (NULL, DEBUG_INIT, -1, NULL, NULL, NULL, "gpgme-dinfo: gpgconf='%s' [not installed]\n", pgmname); free (pgmname); pgmname = NULL; /* Not available. */ } else - _gpgme_debug (DEBUG_INIT, -1, NULL, NULL, NULL, + _gpgme_debug (NULL, DEBUG_INIT, -1, NULL, NULL, NULL, "gpgme-dinfo: gpgconf='%s'\n", pgmname? pgmname : "[null]"); if (!pgmname) @@ -295,35 +295,35 @@ get_gpgconf_item (int what) allocated. */ dirinfo.valid = 1; if (dirinfo.gpg_name) - _gpgme_debug (DEBUG_INIT, -1, NULL, NULL, NULL, + _gpgme_debug (NULL, DEBUG_INIT, -1, NULL, NULL, NULL, "gpgme-dinfo: gpg='%s'\n", dirinfo.gpg_name); if (dirinfo.g13_name) - _gpgme_debug (DEBUG_INIT, -1, NULL, NULL, NULL, + _gpgme_debug (NULL, DEBUG_INIT, -1, NULL, NULL, NULL, "gpgme-dinfo: g13='%s'\n", dirinfo.g13_name); if (dirinfo.gpgsm_name) - _gpgme_debug (DEBUG_INIT, -1, NULL, NULL, NULL, + _gpgme_debug (NULL, DEBUG_INIT, -1, NULL, NULL, NULL, "gpgme-dinfo: gpgsm='%s'\n", dirinfo.gpgsm_name); if (dirinfo.homedir) - _gpgme_debug (DEBUG_INIT, -1, NULL, NULL, NULL, + _gpgme_debug (NULL, DEBUG_INIT, -1, NULL, NULL, NULL, "gpgme-dinfo: homedir='%s'\n", dirinfo.homedir); if (dirinfo.agent_socket) - _gpgme_debug (DEBUG_INIT, -1, NULL, NULL, NULL, + _gpgme_debug (NULL,DEBUG_INIT, -1, NULL, NULL, NULL, "gpgme-dinfo: agent='%s'\n", dirinfo.agent_socket); if (dirinfo.agent_ssh_socket) - _gpgme_debug (DEBUG_INIT, -1, NULL, NULL, NULL, + _gpgme_debug (NULL, DEBUG_INIT, -1, NULL, NULL, NULL, "gpgme-dinfo: ssh='%s'\n", dirinfo.agent_ssh_socket); if (dirinfo.dirmngr_socket) - _gpgme_debug (DEBUG_INIT, -1, NULL, NULL, NULL, + _gpgme_debug (NULL, DEBUG_INIT, -1, NULL, NULL, NULL, "gpgme-dinfo: dirmngr='%s'\n", dirinfo.dirmngr_socket); if (dirinfo.uisrv_socket) - _gpgme_debug (DEBUG_INIT, -1, NULL, NULL, NULL, + _gpgme_debug (NULL, DEBUG_INIT, -1, NULL, NULL, NULL, "gpgme-dinfo: uisrv='%s'\n", dirinfo.uisrv_socket); } diff --git a/src/engine-assuan.c b/src/engine-assuan.c index 79e826e0..497397db 100644 --- a/src/engine-assuan.c +++ b/src/engine-assuan.c @@ -658,7 +658,7 @@ add_io_cb (engine_llass_t llass, iocb_data_t *iocbd, gpgme_io_cb_t handler) gpgme_error_t err; TRACE_BEG (DEBUG_ENGINE, "engine-assuan:add_io_cb", llass, - "fd %d, dir %d", iocbd->fd, iocbd->dir); + "fd=%d, dir %d", iocbd->fd, iocbd->dir); err = (*llass->io_cbs.add) (llass->io_cbs.add_priv, iocbd->fd, iocbd->dir, handler, iocbd->data, &iocbd->tag); diff --git a/src/engine-g13.c b/src/engine-g13.c index edb8d54f..19dd8f47 100644 --- a/src/engine-g13.c +++ b/src/engine-g13.c @@ -639,7 +639,7 @@ add_io_cb (engine_g13_t g13, iocb_data_t *iocbd, gpgme_io_cb_t handler) gpgme_error_t err; TRACE_BEG (DEBUG_ENGINE, "engine-g13:add_io_cb", g13, - "fd %d, dir %d", iocbd->fd, iocbd->dir); + "fd=%d, dir %d", iocbd->fd, iocbd->dir); err = (*g13->io_cbs.add) (g13->io_cbs.add_priv, iocbd->fd, iocbd->dir, handler, iocbd->data, &iocbd->tag); diff --git a/src/engine-gpgsm.c b/src/engine-gpgsm.c index 62920473..ae5d8ef1 100644 --- a/src/engine-gpgsm.c +++ b/src/engine-gpgsm.c @@ -1127,7 +1127,7 @@ add_io_cb (engine_gpgsm_t gpgsm, iocb_data_t *iocbd, gpgme_io_cb_t handler) gpgme_error_t err; TRACE_BEG (DEBUG_ENGINE, "engine-gpgsm:add_io_cb", gpgsm, - "fd %d, dir %d", iocbd->fd, iocbd->dir); + "fd=%d, dir %d", iocbd->fd, iocbd->dir); err = (*gpgsm->io_cbs.add) (gpgsm->io_cbs.add_priv, iocbd->fd, iocbd->dir, handler, iocbd->data, &iocbd->tag); diff --git a/src/engine-uiserver.c b/src/engine-uiserver.c index 62c4e5b6..cb8e155d 100644 --- a/src/engine-uiserver.c +++ b/src/engine-uiserver.c @@ -879,7 +879,7 @@ add_io_cb (engine_uiserver_t uiserver, iocb_data_t *iocbd, gpgme_io_cb_t handler gpgme_error_t err; TRACE_BEG (DEBUG_ENGINE, "engine-uiserver:add_io_cb", uiserver, - "fd %d, dir %d", iocbd->fd, iocbd->dir); + "fd=%d, dir %d", iocbd->fd, iocbd->dir); err = (*uiserver->io_cbs.add) (uiserver->io_cbs.add_priv, iocbd->fd, iocbd->dir, handler, iocbd->data, &iocbd->tag); diff --git a/src/posix-io.c b/src/posix-io.c index be084312..aee7a4d9 100644 --- a/src/posix-io.c +++ b/src/posix-io.c @@ -109,8 +109,8 @@ int _gpgme_io_read (int fd, void *buffer, size_t count) { int nread; - TRACE_BEG (DEBUG_SYSIO, "_gpgme_io_read", fd, - "buffer=%p, count=%zu", buffer, count); + TRACE_BEG (DEBUG_SYSIO, "_gpgme_io_read", NULL, + "fd=%d buffer=%p count=%zu", fd, buffer, count); do { @@ -127,8 +127,8 @@ int _gpgme_io_write (int fd, const void *buffer, size_t count) { int nwritten; - TRACE_BEG (DEBUG_SYSIO, "_gpgme_io_write", fd, - "buffer=%p, count=%zu", buffer, count); + TRACE_BEG (DEBUG_SYSIO, "_gpgme_io_write", NULL, + "fd=%d buffer=%p count=%zu", fd, buffer, count); TRACE_LOGBUFX (buffer, count); do @@ -146,7 +146,7 @@ _gpgme_io_pipe (int filedes[2], int inherit_idx) { int saved_errno; int err; - TRACE_BEG (DEBUG_SYSIO, "_gpgme_io_pipe", filedes, + TRACE_BEG (DEBUG_SYSIO, "_gpgme_io_pipe", NULL, "inherit_idx=%i (GPGME uses it for %s)", inherit_idx, inherit_idx ? "reading" : "writing"); @@ -166,7 +166,7 @@ _gpgme_io_pipe (int filedes[2], int inherit_idx) if (err) return TRACE_SYSRES (err); - TRACE_SUC ("read=0x%x, write=0x%x", filedes[0], filedes[1]); + TRACE_SUC ("read fd=%d write fd=%d", filedes[0], filedes[1]); return 0; } @@ -179,7 +179,7 @@ _gpgme_io_close (int fd) void *handler_value; int idx; - TRACE_BEG (DEBUG_SYSIO, "_gpgme_io_close", fd, ""); + TRACE_BEG (DEBUG_SYSIO, "_gpgme_io_close", NULL, "fd=%d", fd); if (fd == -1) { @@ -221,8 +221,8 @@ _gpgme_io_set_close_notify (int fd, _gpgme_close_notify_handler_t handler, int res = 0; int idx; - TRACE_BEG (DEBUG_SYSIO, "_gpgme_io_set_close_notify", fd, - "close_handler=%p/%p", handler, value); + TRACE_BEG (DEBUG_SYSIO, "_gpgme_io_set_close_notify", NULL, + "fd=%d close_handler=%p/%p", fd, handler, value); assert (fd != -1); @@ -272,7 +272,7 @@ _gpgme_io_set_nonblocking (int fd) { int flags; int res; - TRACE_BEG (DEBUG_SYSIO, "_gpgme_io_set_nonblocking", fd, ""); + TRACE_BEG (DEBUG_SYSIO, "_gpgme_io_set_nonblocking", NULL, "fd=%d", fd); flags = fcntl (fd, F_GETFL, 0); if (flags == -1) @@ -428,7 +428,7 @@ get_max_fds (void) } #endif - TRACE (DEBUG_SYSIO, "gpgme:max_fds", 0, "max fds=%ld (%s)", fds, source); + TRACE (DEBUG_SYSIO, "gpgme:max_fds", NULL, "max fds=%ld (%s)", fds, source); return fds; } @@ -474,7 +474,7 @@ _gpgme_io_spawn (const char *path, char *const argv[], unsigned int flags, int status; int signo; - TRACE_BEG (DEBUG_SYSIO, "_gpgme_io_spawn", path, + TRACE_BEG (DEBUG_SYSIO, "_gpgme_io_spawn", NULL, "path=%s", path); i = 0; while (argv[i]) @@ -654,7 +654,7 @@ _gpgme_io_select (struct io_select_fd_s *fds, size_t nfds, int nonblock) /* Use a 1s timeout. */ struct timeval timeout = { 1, 0 }; void *dbg_help = NULL; - TRACE_BEG (DEBUG_SYSIO, "_gpgme_io_select", fds, + TRACE_BEG (DEBUG_SYSIO, "_gpgme_io_select", NULL, "nfds=%zu, nonblock=%u", nfds, nonblock); FD_ZERO (&readfds); @@ -682,7 +682,7 @@ _gpgme_io_select (struct io_select_fd_s *fds, size_t nfds, int nonblock) FD_SET (fds[i].fd, &readfds); if (fds[i].fd > max_fd) max_fd = fds[i].fd; - TRACE_ADD1 (dbg_help, "r0x%x ", fds[i].fd); + TRACE_ADD1 (dbg_help, "r=%d ", fds[i].fd); any = 1; } else if (fds[i].for_write) @@ -697,7 +697,7 @@ _gpgme_io_select (struct io_select_fd_s *fds, size_t nfds, int nonblock) FD_SET (fds[i].fd, &writefds); if (fds[i].fd > max_fd) max_fd = fds[i].fd; - TRACE_ADD1 (dbg_help, "w0x%x ", fds[i].fd); + TRACE_ADD1 (dbg_help, "w=%d ", fds[i].fd); any = 1; } fds[i].signaled = 0; @@ -721,9 +721,9 @@ _gpgme_io_select (struct io_select_fd_s *fds, size_t nfds, int nonblock) for (i = 0; i <= max_fd; i++) { if (FD_ISSET (i, &readfds)) - TRACE_ADD1 (dbg_help, "r0x%x ", i); + TRACE_ADD1 (dbg_help, "r=%d ", i); if (FD_ISSET (i, &writefds)) - TRACE_ADD1 (dbg_help, "w0x%x ", i); + TRACE_ADD1 (dbg_help, "w=%d ", i); } TRACE_END (dbg_help, "]"); } @@ -760,8 +760,8 @@ _gpgme_io_recvmsg (int fd, struct msghdr *msg, int flags) int nread; int saved_errno; struct iovec *iov; - TRACE_BEG (DEBUG_SYSIO, "_gpgme_io_recvmsg", fd, - "msg=%p, flags=%i", msg, flags); + TRACE_BEG (DEBUG_SYSIO, "_gpgme_io_recvmsg", NULL, + "fd=%d msg=%p flags=%i", fd, msg, flags); nread = 0; iov = msg->msg_iov; @@ -802,8 +802,8 @@ _gpgme_io_sendmsg (int fd, const struct msghdr *msg, int flags) { int nwritten; struct iovec *iov; - TRACE_BEG (DEBUG_SYSIO, "_gpgme_io_sendmsg", fd, - "msg=%p, flags=%i", msg, flags); + TRACE_BEG (DEBUG_SYSIO, "_gpgme_io_sendmsg", NULL, + "fd=%d msg=%p flags=%i", fd, msg, flags); nwritten = 0; iov = msg->msg_iov; @@ -841,7 +841,7 @@ _gpgme_io_dup (int fd) new_fd = dup (fd); while (new_fd == -1 && errno == EINTR); - TRACE (DEBUG_SYSIO, "_gpgme_io_dup", fd, "new fd==%i", new_fd); + TRACE (DEBUG_SYSIO, "_gpgme_io_dup", NULL, "fd=%d -> fd=%d", fd, new_fd); return new_fd; } @@ -852,8 +852,8 @@ _gpgme_io_socket (int domain, int type, int proto) { int res; - TRACE_BEG (DEBUG_SYSIO, "_gpgme_io_socket", domain, - "type=%i, proto=%i", type, proto); + TRACE_BEG (DEBUG_SYSIO, "_gpgme_io_socket", NULL, + "domain=%d type=%i proto=%i", domain, type, proto); res = socket (domain, type, proto); @@ -866,8 +866,8 @@ _gpgme_io_connect (int fd, struct sockaddr *addr, int addrlen) { int res; - TRACE_BEG (DEBUG_SYSIO, "_gpgme_io_connect", fd, - "addr=%p, addrlen=%i", addr, addrlen); + TRACE_BEG (DEBUG_SYSIO, "_gpgme_io_connect", NULL, + "fd=%d addr=%p addrlen=%i", fd, addr, addrlen); do res = ath_connect (fd, addr, addrlen); diff --git a/src/posix-util.c b/src/posix-util.c index cddb31f4..5c4f3390 100644 --- a/src/posix-util.c +++ b/src/posix-util.c @@ -114,7 +114,7 @@ walk_path (const char *pgm) path = s + 1; } - _gpgme_debug (DEBUG_ENGINE, -1, NULL, NULL, NULL, + _gpgme_debug (NULL, DEBUG_ENGINE, -1, NULL, NULL, NULL, "gpgme-walk_path: '%s' not found in '%s'", pgm, orig_path); diff --git a/src/version.c b/src/version.c index 3bf12e94..5beb63a3 100644 --- a/src/version.c +++ b/src/version.c @@ -202,7 +202,7 @@ gpgme_check_version (const char *req_version) before using the trace facility. If we won't the trace would automagically initialize the debug system with out the locks being initialized and missing the assuan log level setting. */ - TRACE (DEBUG_INIT, "gpgme_check_version", 0, + TRACE (DEBUG_INIT, "gpgme_check_version", NULL, "req_version=%s, VERSION=%s", req_version? req_version:"(null)", VERSION); @@ -229,13 +229,13 @@ gpgme_check_version_internal (const char *req_version, return result; /* Catch-22, see above. */ - TRACE (DEBUG_INIT, "gpgme_check_version_internal", 0, + TRACE (DEBUG_INIT, "gpgme_check_version_internal", NULL, "req_version=%s, offset_sig_validity=%zu", req_version ? req_version : "(null)", offset_sig_validity); if (offset_sig_validity != offsetof (struct _gpgme_signature, validity)) { - TRACE (DEBUG_INIT, "gpgme_check_version_internal", 0, + TRACE (DEBUG_INIT, "gpgme_check_version_internal", NULL, "offset_sig_validity mismatch: expected %i", (int)offsetof (struct _gpgme_signature, validity)); _gpgme_selftest = GPG_ERR_SELFTEST_FAILED; diff --git a/src/w32-glib-io.c b/src/w32-glib-io.c index e2e3b8ab..09ffffa2 100644 --- a/src/w32-glib-io.c +++ b/src/w32-glib-io.c @@ -324,7 +324,7 @@ _gpgme_io_write (int fd, const void *buffer, size_t count) chan = find_channel (fd); if (!chan) { - TRACE_LOG ("fd %d: no channel registered"); + TRACE_LOG ("fd=%d: no channel registered"); errno = EINVAL; return -1; } @@ -1067,7 +1067,7 @@ _gpgme_io_connect (int fd, struct sockaddr *addr, int addrlen) return TRACE_SYSRES (-1); } - TRACE_LOG ("connect sockfd=0x%x", sockfd); + TRACE_LOG ("connect socket fd=%d", sockfd); res = connect (sockfd, addr, addrlen); /* FIXME: Error ignored here. */ diff --git a/src/w32-util.c b/src/w32-util.c index fba43448..82076762 100644 --- a/src/w32-util.c +++ b/src/w32-util.c @@ -262,19 +262,19 @@ _gpgme_allow_set_foreground_window (pid_t pid) if (!pid || pid == (pid_t)(-1)) { - TRACE (DEBUG_ENGINE, "gpgme:AllowSetForegroundWindow", 0, + TRACE (DEBUG_ENGINE, "gpgme:AllowSetForegroundWindow", NULL, "no action for pid %d", (int)pid); } else if (func) { int rc = func (pid); - TRACE (DEBUG_ENGINE, "gpgme:AllowSetForegroundWindow", 0, + TRACE (DEBUG_ENGINE, "gpgme:AllowSetForegroundWindow", NULL, "called for pid %d; result=%d", (int)pid, rc); } else { - TRACE (DEBUG_ENGINE, "gpgme:AllowSetForegroundWindow", 0, + TRACE (DEBUG_ENGINE, "gpgme:AllowSetForegroundWindow", NULL, "function not available"); } #endif /* HAVE_ALLOW_SET_FOREGROUND_WINDOW */ @@ -310,13 +310,13 @@ _gpgme_w32_cancel_synchronous_io (HANDLE thread) { if (!func (thread) && GetLastError() != ERROR_NOT_FOUND) { - TRACE (DEBUG_ENGINE, "gpgme:CancelSynchronousIo", 0, + TRACE (DEBUG_ENGINE, "gpgme:CancelSynchronousIo", NULL, "called for thread %p: ec=%d", thread, GetLastError ()); } } else { - TRACE (DEBUG_ENGINE, "gpgme:CancelSynchronousIo", 0, + TRACE (DEBUG_ENGINE, "gpgme:CancelSynchronousIo", NULL, "function not available"); } } @@ -578,7 +578,7 @@ _gpgme_get_gpg_path (void) /* 4. Print a debug message if not found. */ if (!gpg) - _gpgme_debug (DEBUG_ENGINE, -1, NULL, NULL, NULL, + _gpgme_debug (NULL, DEBUG_ENGINE, -1, NULL, NULL, NULL, "_gpgme_get_gpg_path: '%s' not found", name); return gpg; @@ -654,7 +654,7 @@ _gpgme_get_gpgconf_path (void) /* 5. Print a debug message if not found. */ if (!gpgconf) - _gpgme_debug (DEBUG_ENGINE, -1, NULL, NULL, NULL, + _gpgme_debug (NULL, DEBUG_ENGINE, -1, NULL, NULL, NULL, "_gpgme_get_gpgconf_path: '%s' not found",name); return gpgconf; diff --git a/src/wait.c b/src/wait.c index 1da9e93d..e6161018 100644 --- a/src/wait.c +++ b/src/wait.c @@ -137,7 +137,7 @@ _gpgme_add_io_cb (void *data, int fd, int dir, gpgme_io_cb_t fnc, } TRACE (DEBUG_CTX, "_gpgme_add_io_cb", ctx, - "fd %d, dir=%d -> tag=%p", fd, dir, tag); + "fd=%d, dir=%d -> tag=%p", fd, dir, tag); *r_tag = tag; return 0;