diff options
author | Ingo Klöcker <[email protected]> | 2021-08-03 10:09:13 +0000 |
---|---|---|
committer | Ingo Klöcker <[email protected]> | 2021-08-03 10:13:27 +0000 |
commit | 7cfc93193d535ec5037e48b86544e1b4dbf949f6 (patch) | |
tree | 90e94dd683fb4a472c4f55b413f4c44e13274f76 /src/debug.h | |
parent | core: Support closefrom also for glibc. (diff) | |
download | gpgme-7cfc93193d535ec5037e48b86544e1b4dbf949f6.tar.gz gpgme-7cfc93193d535ec5037e48b86544e1b4dbf949f6.zip |
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
Diffstat (limited to 'src/debug.h')
-rw-r--r-- | src/debug.h | 34 |
1 files changed, 33 insertions, 1 deletions
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__) |