From cf423864062a2677d0eeabbb11462a788f527b4c Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Fri, 16 Nov 2018 16:57:09 +0100 Subject: [PATCH] core: Fix format string errors in trace macros -- Signed-off-by: Werner Koch --- src/data-compat.c | 10 +++++----- src/data-mem.c | 4 ++-- src/data.c | 12 ++++++------ src/debug.c | 2 +- src/gpgme.c | 6 +++--- src/import.c | 3 ++- src/posix-io.c | 8 ++++---- src/queryswdb.c | 2 +- src/trustlist.c | 6 +++--- src/verify.c | 2 +- src/version.c | 4 ++-- 11 files changed, 30 insertions(+), 29 deletions(-) diff --git a/src/data-compat.c b/src/data-compat.c index 830b42c6..9091b968 100644 --- a/src/data-compat.c +++ b/src/data-compat.c @@ -48,8 +48,8 @@ gpgme_data_new_from_filepart (gpgme_data_t *r_dh, const char *fname, int res; TRACE_BEG (DEBUG_DATA, "gpgme_data_new_from_filepart", r_dh, - "file_name=%s, stream=%p, offset=%lli, length=%u", - fname, stream, offset, length); + "file_name=%s, stream=%p, offset=%lli, length=%zu", + fname, stream, (long long int)offset, length); if (stream && fname) return TRACE_ERR (gpg_error (GPG_ERR_INV_VALUE)); @@ -173,13 +173,13 @@ old_user_read (gpgme_data_t dh, void *buffer, size_t size) gpgme_error_t err; size_t amt; TRACE_BEG (DEBUG_DATA, "gpgme:old_user_read", dh, - "buffer=%p, size=%u", buffer, size); + "buffer=%p, size=%zu", buffer, size); err = (*dh->data.old_user.cb) (dh->data.old_user.handle, buffer, size, &amt); if (err) return TRACE_SYSRES (gpgme_error_to_errno (err)); - return TRACE_SYSRES ((gpgme_ssize_t)amt); + return TRACE_SYSRES ((int)amt); } @@ -188,7 +188,7 @@ old_user_seek (gpgme_data_t dh, gpgme_off_t offset, int whence) { gpgme_error_t err; TRACE_BEG (DEBUG_DATA, "gpgme:old_user_seek", dh, - "offset=%llu, whence=%i", offset, whence); + "offset=%llu, whence=%i", (long long int)offset, whence); if (whence != SEEK_SET || offset) { diff --git a/src/data-mem.c b/src/data-mem.c index c461a606..915c3e00 100644 --- a/src/data-mem.c +++ b/src/data-mem.c @@ -190,7 +190,7 @@ gpgme_data_new_from_mem (gpgme_data_t *r_dh, const char *buffer, { gpgme_error_t err; TRACE_BEG (DEBUG_DATA, "gpgme_data_new_from_mem", r_dh, - "buffer=%p, size=%u, copy=%i (%s)", buffer, size, + "buffer=%p, size=%zu, copy=%i (%s)", buffer, size, copy, copy ? "yes" : "no"); err = _gpgme_data_new (r_dh, &mem_cbs); @@ -283,7 +283,7 @@ gpgme_data_release_and_get_mem (gpgme_data_t dh, size_t *r_len) if (r_len) { - TRACE_SUC ("buffer=%p, len=%u", str, *r_len); + TRACE_SUC ("buffer=%p, len=%zu", str, *r_len); } else { diff --git a/src/data.c b/src/data.c index f633e08c..44ef2d3d 100644 --- a/src/data.c +++ b/src/data.c @@ -353,7 +353,7 @@ gpgme_data_read (gpgme_data_t dh, void *buffer, size_t size) gpgme_ssize_t res; int blankout; TRACE_BEG (DEBUG_DATA, "gpgme_data_read", dh, - "buffer=%p, size=%u", buffer, size); + "buffer=%p, size=%zu", buffer, size); if (!dh) { @@ -376,7 +376,7 @@ gpgme_data_read (gpgme_data_t dh, void *buffer, size_t size) while (res < 0 && errno == EINTR); } - return TRACE_SYSRES (res); + return TRACE_SYSRES ((int)res); } @@ -388,7 +388,7 @@ gpgme_data_write (gpgme_data_t dh, const void *buffer, size_t size) { gpgme_ssize_t res; TRACE_BEG (DEBUG_DATA, "gpgme_data_write", dh, - "buffer=%p, size=%u", buffer, size); + "buffer=%p, size=%zu", buffer, size); if (!dh) { @@ -404,7 +404,7 @@ gpgme_data_write (gpgme_data_t dh, const void *buffer, size_t size) res = (*dh->cbs->write) (dh, buffer, size); while (res < 0 && errno == EINTR); - return TRACE_SYSRES (res); + return TRACE_SYSRES ((int)res); } @@ -415,7 +415,7 @@ gpgme_off_t gpgme_data_seek (gpgme_data_t dh, gpgme_off_t offset, int whence) { TRACE_BEG (DEBUG_DATA, "gpgme_data_seek", dh, - "offset=%lli, whence=%i", offset, whence); + "offset=%lli, whence=%i", (long long int)offset, whence); if (!dh) { @@ -437,7 +437,7 @@ gpgme_data_seek (gpgme_data_t dh, gpgme_off_t offset, int whence) if (offset >= 0) dh->pending_len = 0; - return TRACE_SYSRES (offset); + return TRACE_SYSRES ((int)offset); } diff --git a/src/debug.c b/src/debug.c index 29f7dc6d..f0b0da0e 100644 --- a/src/debug.c +++ b/src/debug.c @@ -379,7 +379,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", *line); + _gpgme_debug (1, -1, NULL, NULL, NULL, "%s", (char*)*line); gpgrt_free (*line); *line = NULL; } diff --git a/src/gpgme.c b/src/gpgme.c index ac98bd59..c4a1da11 100644 --- a/src/gpgme.c +++ b/src/gpgme.c @@ -911,7 +911,7 @@ gpgme_io_read (int fd, void *buffer, size_t count) { int ret; TRACE_BEG (DEBUG_GLOBAL, "gpgme_io_read", fd, - "buffer=%p, count=%u", buffer, count); + "buffer=%p, count=%zu", buffer, count); ret = _gpgme_io_read (fd, buffer, count); @@ -927,7 +927,7 @@ gpgme_io_write (int fd, const void *buffer, size_t count) { int ret; TRACE_BEG (DEBUG_GLOBAL, "gpgme_io_write", fd, - "buffer=%p, count=%u", buffer, count); + "buffer=%p, count=%zu", buffer, count); ret = _gpgme_io_write (fd, buffer, count); @@ -946,7 +946,7 @@ gpgme_io_writen (int fd, const void *buffer_arg, size_t count) const char *buffer = buffer_arg; int ret = 0; TRACE_BEG (DEBUG_GLOBAL, "gpgme_io_writen", fd, - "buffer=%p, count=%u", buffer, count); + "buffer=%p, count=%zu", buffer, count); while (count) { ret = _gpgme_io_write (fd, buffer, count); diff --git a/src/import.c b/src/import.c index 3d49146f..2834aec2 100644 --- a/src/import.c +++ b/src/import.c @@ -103,7 +103,8 @@ gpgme_op_import_result (gpgme_ctx_t ctx) while (impstat) { TRACE_LOG ("import[%i] for %s = 0x%x (%s)", - i, impstat->fpr, impstat->status, impstat->result); + i, impstat->fpr, impstat->status, + gpgme_strerror (impstat->result)); impstat = impstat->next; i++; } diff --git a/src/posix-io.c b/src/posix-io.c index 78f523b1..77ecde05 100644 --- a/src/posix-io.c +++ b/src/posix-io.c @@ -110,7 +110,7 @@ _gpgme_io_read (int fd, void *buffer, size_t count) { int nread; TRACE_BEG (DEBUG_SYSIO, "_gpgme_io_read", fd, - "buffer=%p, count=%u", buffer, count); + "buffer=%p, count=%zu", buffer, count); do { @@ -128,7 +128,7 @@ _gpgme_io_write (int fd, const void *buffer, size_t count) { int nwritten; TRACE_BEG (DEBUG_SYSIO, "_gpgme_io_write", fd, - "buffer=%p, count=%u", buffer, count); + "buffer=%p, count=%zu", buffer, count); TRACE_LOGBUFX (buffer, count); do @@ -427,7 +427,7 @@ get_max_fds (void) } #endif - TRACE (DEBUG_SYSIO, "gpgme:max_fds", 0, "max fds=%i (%s)", fds, source); + TRACE (DEBUG_SYSIO, "gpgme:max_fds", 0, "max fds=%ld (%s)", fds, source); return fds; } @@ -654,7 +654,7 @@ _gpgme_io_select (struct io_select_fd_s *fds, size_t nfds, int nonblock) struct timeval timeout = { 1, 0 }; void *dbg_help = NULL; TRACE_BEG (DEBUG_SYSIO, "_gpgme_io_select", fds, - "nfds=%u, nonblock=%u", nfds, nonblock); + "nfds=%zu, nonblock=%u", nfds, nonblock); FD_ZERO (&readfds); FD_ZERO (&writefds); diff --git a/src/queryswdb.c b/src/queryswdb.c index e72dabbc..2b7a07f5 100644 --- a/src/queryswdb.c +++ b/src/queryswdb.c @@ -92,7 +92,7 @@ gpgme_op_query_swdb (gpgme_ctx_t ctx, const char *name, const char *iversion, op_data_t opd; TRACE_BEG (DEBUG_CTX, "gpgme_op_query_swdb", ctx, - "name=%s, iversion=%", name, iversion); + "name=%s, iversion=%s", name, iversion); if (!ctx || reserved) return TRACE_ERR (gpg_error (GPG_ERR_INV_VALUE)); diff --git a/src/trustlist.c b/src/trustlist.c index c7778379..a0e82385 100644 --- a/src/trustlist.c +++ b/src/trustlist.c @@ -246,20 +246,20 @@ gpgme_op_trustlist_next (gpgme_ctx_t ctx, gpgme_trust_item_t *r_item) if ((*r_item)->type == 1) { TRACE_SUC ("trust_item=%p: %s: owner trust %s with level %i " - "and validity 0x%x", *r_item, (*r_item)->keyid, + "and validity %s", *r_item, (*r_item)->keyid, (*r_item)->owner_trust, (*r_item)->level, (*r_item)->validity); } else if ((*r_item)->type == 2) { TRACE_SUC ("trust_item=%p: %s: UID %s with level %i " - "and validity 0x%x", *r_item, (*r_item)->keyid, + "and validity %s", *r_item, (*r_item)->keyid, (*r_item)->name, (*r_item)->level, (*r_item)->validity); } else { TRACE_SUC ("trust_item=%p: %s: unknown type %i with level %i " - "and validity 0x%x", *r_item, (*r_item)->keyid, + "and validity %s", *r_item, (*r_item)->keyid, (*r_item)->type, (*r_item)->level, (*r_item)->validity); } return 0; diff --git a/src/verify.c b/src/verify.c index 78e549ed..8aa9d281 100644 --- a/src/verify.c +++ b/src/verify.c @@ -135,7 +135,7 @@ gpgme_op_verify_result (gpgme_ctx_t ctx) { TRACE_LOG ("sig[%i] = fpr %s, summary 0x%x, status %s", i, sig->fpr, sig->summary, gpg_strerror (sig->status)); - TRACE_LOG ("sig[%i] = timestamps 0x%x/0x%x flags:%s%s%s", + TRACE_LOG ("sig[%i] = timestamps 0x%lx/0x%lx flags:%s%s%s", i, sig->timestamp, sig->exp_timestamp, sig->wrong_key_usage ? "wrong key usage" : "", sig->pka_trust == 1 ? "pka bad" diff --git a/src/version.c b/src/version.c index 8c35ed0e..3bf12e94 100644 --- a/src/version.c +++ b/src/version.c @@ -230,14 +230,14 @@ gpgme_check_version_internal (const char *req_version, /* Catch-22, see above. */ TRACE (DEBUG_INIT, "gpgme_check_version_internal", 0, - "req_version=%s, offset_sig_validity=%i", + "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, "offset_sig_validity mismatch: expected %i", - offsetof (struct _gpgme_signature, validity)); + (int)offsetof (struct _gpgme_signature, validity)); _gpgme_selftest = GPG_ERR_SELFTEST_FAILED; }