diff --git a/src/data.c b/src/data.c index 62b72312..e2de9f67 100644 --- a/src/data.c +++ b/src/data.c @@ -391,7 +391,7 @@ gpgme_data_read (gpgme_data_t dh, void *buffer, size_t size) while (res < 0 && errno == EINTR); } - return TRACE_SYSRES ((int)res); + return TRACE_SYSRES_SSIZE_T (res); } @@ -419,7 +419,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 ((int)res); + return TRACE_SYSRES_SSIZE_T (res); } @@ -452,7 +452,7 @@ gpgme_data_seek (gpgme_data_t dh, gpgme_off_t offset, int whence) if (offset >= 0) dh->outbound_pending = 0; - return TRACE_SYSRES ((int)offset); + return TRACE_SYSRES_OFF_T (offset); } 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__)