diff options
author | Michal Schmidt <mschmidt@redhat.com> | 2014-11-28 19:29:59 +0100 |
---|---|---|
committer | Michal Schmidt <mschmidt@redhat.com> | 2014-11-28 19:49:27 +0100 |
commit | 56f64d95763a799ba4475daf44d8e9f72a1bd474 (patch) | |
tree | 4c38253c718dc1972b811fa7c01ebfa3c2b7776c /src/journal-remote | |
parent | 895b3a7b44fe7ca2f260986be2a877ff56a72718 (diff) |
treewide: use log_*_errno whenever %m is in the format string
If the format string contains %m, clearly errno must have a meaningful
value, so we might as well use log_*_errno to have ERRNO= logged.
Using:
find . -name '*.[ch]' | xargs sed -r -i -e \
's/log_(debug|info|notice|warning|error|emergency)\((".*%m.*")/log_\1_errno(errno, \2/'
Plus some whitespace, linewrap, and indent adjustments.
Diffstat (limited to 'src/journal-remote')
-rw-r--r-- | src/journal-remote/journal-gatewayd.c | 12 | ||||
-rw-r--r-- | src/journal-remote/journal-remote-parse.c | 4 | ||||
-rw-r--r-- | src/journal-remote/journal-remote.c | 18 | ||||
-rw-r--r-- | src/journal-remote/journal-upload.c | 4 |
4 files changed, 19 insertions, 19 deletions
diff --git a/src/journal-remote/journal-gatewayd.c b/src/journal-remote/journal-gatewayd.c index d39a2cc67e..7a99430a63 100644 --- a/src/journal-remote/journal-gatewayd.c +++ b/src/journal-remote/journal-gatewayd.c @@ -198,7 +198,7 @@ static ssize_t request_reader_entries( else { m->tmp = tmpfile(); if (!m->tmp) { - log_error("Failed to create temporary file: %m"); + log_error_errno(errno, "Failed to create temporary file: %m"); return MHD_CONTENT_READER_END_WITH_ERROR; } } @@ -211,7 +211,7 @@ static ssize_t request_reader_entries( sz = ftello(m->tmp); if (sz == (off_t) -1) { - log_error("Failed to retrieve file position: %m"); + log_error_errno(errno, "Failed to retrieve file position: %m"); return MHD_CONTENT_READER_END_WITH_ERROR; } @@ -219,7 +219,7 @@ static ssize_t request_reader_entries( } if (fseeko(m->tmp, pos, SEEK_SET) < 0) { - log_error("Failed to seek to position: %m"); + log_error_errno(errno, "Failed to seek to position: %m"); return MHD_CONTENT_READER_END_WITH_ERROR; } @@ -559,7 +559,7 @@ static ssize_t request_reader_fields( else { m->tmp = tmpfile(); if (!m->tmp) { - log_error("Failed to create temporary file: %m"); + log_error_errno(errno, "Failed to create temporary file: %m"); return MHD_CONTENT_READER_END_WITH_ERROR; } } @@ -572,7 +572,7 @@ static ssize_t request_reader_fields( sz = ftello(m->tmp); if (sz == (off_t) -1) { - log_error("Failed to retrieve file position: %m"); + log_error_errno(errno, "Failed to retrieve file position: %m"); return MHD_CONTENT_READER_END_WITH_ERROR; } @@ -580,7 +580,7 @@ static ssize_t request_reader_fields( } if (fseeko(m->tmp, pos, SEEK_SET) < 0) { - log_error("Failed to seek to position: %m"); + log_error_errno(errno, "Failed to seek to position: %m"); return MHD_CONTENT_READER_END_WITH_ERROR; } diff --git a/src/journal-remote/journal-remote-parse.c b/src/journal-remote/journal-remote-parse.c index 47ff368e6c..76407f711b 100644 --- a/src/journal-remote/journal-remote-parse.c +++ b/src/journal-remote/journal-remote-parse.c @@ -125,7 +125,7 @@ static int get_line(RemoteSource *source, char **line, size_t *size) { source->size - source->filled); if (n < 0) { if (errno != EAGAIN && errno != EWOULDBLOCK) - log_error("read(%d, ..., %zd): %m", source->fd, + log_error_errno(errno, "read(%d, ..., %zd): %m", source->fd, source->size - source->filled); return -errno; } else if (n == 0) @@ -186,7 +186,7 @@ static int fill_fixed_size(RemoteSource *source, void **data, size_t size) { source->size - source->filled); if (n < 0) { if (errno != EAGAIN && errno != EWOULDBLOCK) - log_error("read(%d, ..., %zd): %m", source->fd, + log_error_errno(errno, "read(%d, ..., %zd): %m", source->fd, source->size - source->filled); return -errno; } else if (n == 0) diff --git a/src/journal-remote/journal-remote.c b/src/journal-remote/journal-remote.c index 78385538b4..06a39920e4 100644 --- a/src/journal-remote/journal-remote.c +++ b/src/journal-remote/journal-remote.c @@ -85,7 +85,7 @@ static int spawn_child(const char* child, char** argv) { int r; if (pipe(fd) < 0) { - log_error("Failed to create pager pipe: %m"); + log_error_errno(errno, "Failed to create pager pipe: %m"); return -errno; } @@ -94,7 +94,7 @@ static int spawn_child(const char* child, char** argv) { child_pid = fork(); if (child_pid < 0) { r = -errno; - log_error("Failed to fork: %m"); + log_error_errno(errno, "Failed to fork: %m"); safe_close_pair(fd); return r; } @@ -103,7 +103,7 @@ static int spawn_child(const char* child, char** argv) { if (child_pid == 0) { r = dup2(fd[1], STDOUT_FILENO); if (r < 0) { - log_error("Failed to dup pipe to stdout: %m"); + log_error_errno(errno, "Failed to dup pipe to stdout: %m"); _exit(EXIT_FAILURE); } @@ -119,13 +119,13 @@ static int spawn_child(const char* child, char** argv) { _exit(EXIT_SUCCESS); execvp(child, argv); - log_error("Failed to exec child %s: %m", child); + log_error_errno(errno, "Failed to exec child %s: %m", child); _exit(EXIT_FAILURE); } r = close(fd[1]); if (r < 0) - log_warning("Failed to close write end of pipe: %m"); + log_warning_errno(errno, "Failed to close write end of pipe: %m"); return fd[0]; } @@ -140,7 +140,7 @@ static int spawn_curl(const char* url) { r = spawn_child("curl", argv); if (r < 0) - log_error("Failed to spawn curl: %m"); + log_error_errno(errno, "Failed to spawn curl: %m"); return r; } @@ -159,7 +159,7 @@ static int spawn_getter(const char *getter, const char *url) { r = spawn_child(words[0], words); if (r < 0) - log_error("Failed to spawn getter %s: %m", getter); + log_error_errno(errno, "Failed to spawn getter %s: %m", getter); return r; } @@ -941,7 +941,7 @@ static int remoteserver_init(RemoteServer *s, fd = open(*file, O_RDONLY|O_CLOEXEC|O_NOCTTY|O_NONBLOCK); if (fd < 0) { - log_error("Failed to open %s: %m", *file); + log_error_errno(errno, "Failed to open %s: %m", *file); return -errno; } output_name = *file; @@ -1054,7 +1054,7 @@ static int accept_connection(const char* type, int fd, log_debug("Accepting new %s connection on fd:%d", type, fd); fd2 = accept4(fd, &addr->sockaddr.sa, &addr->size, SOCK_NONBLOCK|SOCK_CLOEXEC); if (fd2 < 0) { - log_error("accept() on fd:%d failed: %m", fd); + log_error_errno(errno, "accept() on fd:%d failed: %m", fd); return -errno; } diff --git a/src/journal-remote/journal-upload.c b/src/journal-remote/journal-upload.c index 8da65132ca..826e41a1c4 100644 --- a/src/journal-remote/journal-upload.c +++ b/src/journal-remote/journal-upload.c @@ -308,7 +308,7 @@ static size_t fd_input_callback(void *buf, size_t size, size_t nmemb, void *user close_fd_input(u); return 0; } else { - log_error("Aborting transfer after read error on input: %m."); + log_error_errno(errno, "Aborting transfer after read error on input: %m."); return CURL_READFUNC_ABORT; } } @@ -358,7 +358,7 @@ static int open_file_for_upload(Uploader *u, const char *filename) { else { fd = open(filename, O_RDONLY|O_CLOEXEC|O_NOCTTY); if (fd < 0) { - log_error("Failed to open %s: %m", filename); + log_error_errno(errno, "Failed to open %s: %m", filename); return -errno; } } |