From 7cfc93193d535ec5037e48b86544e1b4dbf949f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ingo=20Kl=C3=B6cker?= Date: Tue, 3 Aug 2021 12:09:13 +0200 Subject: core: Fix results returned by gpgme_data_* functions src/debug.h (TRACE_SYSRES_OFF_T, _trace_sysres_off_t, TRACE_SYSRES_SSIZE_T, _trace_sysres_ssize_t): New. src/data.c (gpgme_data_read, gpgme_data_write, gpgme_data_seek): Use appropriate new tracing macros instead of casting the results to int. -- This change adds tracing macros for results of system functions of type __off_t and __ssize_t. GnuPG-bug-id: 5481 --- src/debug.h | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) (limited to 'src/debug.h') diff --git a/src/debug.h b/src/debug.h index fa0bfc6c..7b823ee1 100644 --- a/src/debug.h +++ b/src/debug.h @@ -141,7 +141,7 @@ _trace_err (gpg_error_t err, int lvl, const char *func, int line) return err; } -/* Trace a system call result and return it. */ +/* Trace a system call result of type int and return it. */ #define TRACE_SYSRES(res) \ _trace_sysres ((res), _gpgme_trace_level, _gpgme_trace_func, __LINE__) static inline int @@ -157,6 +157,38 @@ _trace_sysres (int res, int lvl, const char *func, int line) return res; } +/* Trace a system call result of type gpgme_off_t and return it. */ +#define TRACE_SYSRES_OFF_T(res) \ + _trace_sysres_off_t ((res), _gpgme_trace_level, _gpgme_trace_func, __LINE__) +static inline gpgme_off_t +_trace_sysres_off_t (gpgme_off_t res, int lvl, const char *func, int line) +{ + if (res >= 0) + _gpgme_debug (NULL, lvl, 3, func, NULL, NULL, "result=%ld", res); + else + _gpgme_debug (NULL, lvl, -1, NULL, NULL, NULL, + "%s:%d: error: %s (%d)\n", + func, line, strerror (errno), errno); + _gpgme_debug_frame_end (); + return res; +} + +/* Trace a system call result of type gpgme_ssize_t and return it. */ +#define TRACE_SYSRES_SSIZE_T(res) \ + _trace_sysres_ssize_t ((res), _gpgme_trace_level, _gpgme_trace_func, __LINE__) +static inline gpgme_ssize_t +_trace_sysres_ssize_t (gpgme_ssize_t res, int lvl, const char *func, int line) +{ + if (res >= 0) + _gpgme_debug (NULL, lvl, 3, func, NULL, NULL, "result=%zd", res); + else + _gpgme_debug (NULL, lvl, -1, NULL, NULL, NULL, + "%s:%d: error: %s (%d)\n", + func, line, strerror (errno), errno); + _gpgme_debug_frame_end (); + return res; +} + /* Trace a system call error and return it. */ #define TRACE_SYSERR(rc) \ _trace_syserr ((rc), _gpgme_trace_level, _gpgme_trace_func, __LINE__) -- cgit v1.2.3