diff options
author | Werner Koch <[email protected]> | 2018-11-16 15:25:49 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2018-11-16 15:25:49 +0000 |
commit | 5857491a2aa7d4975100d90f1ad62c08aa345e3e (patch) | |
tree | c433d2da27e7b9f98ca783e15b00087f2ce3d6cd /src/posix-io.c | |
parent | Add SPDX identifiers to most source files (diff) | |
download | gpgme-5857491a2aa7d4975100d90f1ad62c08aa345e3e.tar.gz gpgme-5857491a2aa7d4975100d90f1ad62c08aa345e3e.zip |
core: Simplify the trace maros by using variadics.
* src/debug.h (TRACE_BEG, TRACE_LOG, TRACE_SUC): Use variadic macros
and remove the TRACE_BEG1 et al. Change all users to always pass a
format string.
(TRACE): Ditto.
* src/debug.c (_gpgme_debugf): New.
* configure.ac <GCC>: Add -Wno-format-zero-length.
--
This makes it easier for use to enable format checks. The zero-length
format is required to allow for an empty format due to the comman
problematic of __VA_ARGS__.
Signed-off-by: Werner Koch <[email protected]>
Diffstat (limited to 'src/posix-io.c')
-rw-r--r-- | src/posix-io.c | 46 |
1 files changed, 23 insertions, 23 deletions
diff --git a/src/posix-io.c b/src/posix-io.c index 67c6e392..78f523b1 100644 --- a/src/posix-io.c +++ b/src/posix-io.c @@ -109,7 +109,7 @@ int _gpgme_io_read (int fd, void *buffer, size_t count) { int nread; - TRACE_BEG2 (DEBUG_SYSIO, "_gpgme_io_read", fd, + TRACE_BEG (DEBUG_SYSIO, "_gpgme_io_read", fd, "buffer=%p, count=%u", buffer, count); do @@ -127,7 +127,7 @@ int _gpgme_io_write (int fd, const void *buffer, size_t count) { int nwritten; - TRACE_BEG2 (DEBUG_SYSIO, "_gpgme_io_write", fd, + TRACE_BEG (DEBUG_SYSIO, "_gpgme_io_write", fd, "buffer=%p, count=%u", buffer, count); TRACE_LOGBUFX (buffer, count); @@ -146,7 +146,7 @@ _gpgme_io_pipe (int filedes[2], int inherit_idx) { int saved_errno; int err; - TRACE_BEG2 (DEBUG_SYSIO, "_gpgme_io_pipe", filedes, + TRACE_BEG (DEBUG_SYSIO, "_gpgme_io_pipe", filedes, "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); - return TRACE_SUC2 ("read=0x%x, write=0x%x", filedes[0], filedes[1]); + return TRACE_SUC ("read=0x%x, write=0x%x", filedes[0], filedes[1]); } @@ -178,7 +178,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", fd, ""); if (fd == -1) { @@ -203,7 +203,7 @@ _gpgme_io_close (int fd) UNLOCK (notify_table_lock); if (handler) { - TRACE_LOG2 ("invoking close handler %p/%p", handler, handler_value); + TRACE_LOG ("invoking close handler %p/%p", handler, handler_value); handler (fd, handler_value); } @@ -220,7 +220,7 @@ _gpgme_io_set_close_notify (int fd, _gpgme_close_notify_handler_t handler, int res = 0; int idx; - TRACE_BEG2 (DEBUG_SYSIO, "_gpgme_io_set_close_notify", fd, + TRACE_BEG (DEBUG_SYSIO, "_gpgme_io_set_close_notify", fd, "close_handler=%p/%p", handler, value); assert (fd != -1); @@ -271,7 +271,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", fd, ""); flags = fcntl (fd, F_GETFL, 0); if (flags == -1) @@ -427,7 +427,7 @@ get_max_fds (void) } #endif - TRACE2 (DEBUG_SYSIO, "gpgme:max_fds", 0, "max fds=%i (%s)", fds, source); + TRACE (DEBUG_SYSIO, "gpgme:max_fds", 0, "max fds=%i (%s)", fds, source); return fds; } @@ -473,19 +473,19 @@ _gpgme_io_spawn (const char *path, char *const argv[], unsigned int flags, int status; int signo; - TRACE_BEG1 (DEBUG_SYSIO, "_gpgme_io_spawn", path, + TRACE_BEG (DEBUG_SYSIO, "_gpgme_io_spawn", path, "path=%s", path); i = 0; while (argv[i]) { - TRACE_LOG2 ("argv[%2i] = %s", i, argv[i]); + TRACE_LOG ("argv[%2i] = %s", i, argv[i]); i++; } for (i = 0; fd_list[i].fd != -1; i++) if (fd_list[i].dup_to == -1) - TRACE_LOG2 ("fd[%i] = 0x%x", i, fd_list[i].fd); + TRACE_LOG ("fd[%i] = 0x%x", i, fd_list[i].fd); else - TRACE_LOG3 ("fd[%i] = 0x%x -> 0x%x", i, fd_list[i].fd, fd_list[i].dup_to); + TRACE_LOG ("fd[%i] = 0x%x -> 0x%x", i, fd_list[i].fd, fd_list[i].dup_to); pid = fork (); if (pid == -1) @@ -568,7 +568,7 @@ _gpgme_io_spawn (const char *path, char *const argv[], unsigned int flags, #if 0 /* FIXME: The debug file descriptor is not dup'ed anyway, so we can't see this. */ - TRACE_LOG1 ("dup2 failed in child: %s\n", + TRACE_LOG ("dup2 failed in child: %s\n", strerror (errno)); #endif _exit (8); @@ -618,7 +618,7 @@ _gpgme_io_spawn (const char *path, char *const argv[], unsigned int flags, _exit (0); } - TRACE_LOG1 ("waiting for child process pid=%i", pid); + TRACE_LOG ("waiting for child process pid=%i", pid); _gpgme_io_waitpid (pid, 1, &status, &signo); if (status) return TRACE_SYSRES (-1); @@ -653,7 +653,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_BEG2 (DEBUG_SYSIO, "_gpgme_io_select", fds, + TRACE_BEG (DEBUG_SYSIO, "_gpgme_io_select", fds, "nfds=%u, nonblock=%u", nfds, nonblock); FD_ZERO (&readfds); @@ -759,7 +759,7 @@ _gpgme_io_recvmsg (int fd, struct msghdr *msg, int flags) int nread; int saved_errno; struct iovec *iov; - TRACE_BEG2 (DEBUG_SYSIO, "_gpgme_io_recvmsg", fd, + TRACE_BEG (DEBUG_SYSIO, "_gpgme_io_recvmsg", fd, "msg=%p, flags=%i", msg, flags); nread = 0; @@ -770,7 +770,7 @@ _gpgme_io_recvmsg (int fd, struct msghdr *msg, int flags) iov++; } - TRACE_LOG1 ("about to receive %d bytes", nread); + TRACE_LOG ("about to receive %d bytes", nread); do { @@ -801,7 +801,7 @@ _gpgme_io_sendmsg (int fd, const struct msghdr *msg, int flags) { int nwritten; struct iovec *iov; - TRACE_BEG2 (DEBUG_SYSIO, "_gpgme_io_sendmsg", fd, + TRACE_BEG (DEBUG_SYSIO, "_gpgme_io_sendmsg", fd, "msg=%p, flags=%i", msg, flags); nwritten = 0; @@ -812,7 +812,7 @@ _gpgme_io_sendmsg (int fd, const struct msghdr *msg, int flags) iov++; } - TRACE_LOG1 ("about to receive %d bytes", nwritten); + TRACE_LOG ("about to receive %d bytes", nwritten); iov = msg->msg_iov; while (nwritten > 0) { @@ -840,7 +840,7 @@ _gpgme_io_dup (int fd) new_fd = dup (fd); while (new_fd == -1 && errno == EINTR); - TRACE1 (DEBUG_SYSIO, "_gpgme_io_dup", fd, "new fd==%i", new_fd); + TRACE (DEBUG_SYSIO, "_gpgme_io_dup", fd, "new fd==%i", new_fd); return new_fd; } @@ -851,7 +851,7 @@ _gpgme_io_socket (int domain, int type, int proto) { int res; - TRACE_BEG2 (DEBUG_SYSIO, "_gpgme_io_socket", domain, + TRACE_BEG (DEBUG_SYSIO, "_gpgme_io_socket", domain, "type=%i, proto=%i", type, proto); res = socket (domain, type, proto); @@ -865,7 +865,7 @@ _gpgme_io_connect (int fd, struct sockaddr *addr, int addrlen) { int res; - TRACE_BEG2 (DEBUG_SYSIO, "_gpgme_io_connect", fd, + TRACE_BEG (DEBUG_SYSIO, "_gpgme_io_connect", fd, "addr=%p, addrlen=%i", addr, addrlen); do |