chiark / gitweb /
treewide: more log_*_errno + return simplifications
[elogind.git] / src / journal / journald-audit.c
index f54373250680beee74027cba1dbd03080150ec73..18235d9308043cfeadbbffce4c63c6f19ad43b4c 100644 (file)
@@ -308,10 +308,8 @@ static int map_all_fields(
                                 continue;
 
                         r = m->map(m->journal_field, &v, iov, n_iov_allocated, n_iov);
-                        if (r < 0) {
-                                log_debug("Failed to parse audit array: %s", strerror(-r));
-                                return r;
-                        }
+                        if (r < 0)
+                                return log_debug_errno(r, "Failed to parse audit array: %m");
 
                         if (r > 0) {
                                 mapped = true;
@@ -322,10 +320,8 @@ static int map_all_fields(
 
                 if (!mapped) {
                         r = map_generic_field(prefix, &p, iov, n_iov_allocated, n_iov);
-                        if (r < 0) {
-                                log_debug("Failed to parse audit array: %s", strerror(-r));
-                                return r;
-                        }
+                        if (r < 0)
+                                return log_debug_errno(r, "Failed to parse audit array: %m");
 
                         if (r == 0) {
                                 /* Couldn't process as generic field, let's just skip over it */
@@ -396,8 +392,8 @@ static void process_audit_string(Server *s, int type, const char *data, size_t s
         sprintf(id_field, "_AUDIT_ID=%" PRIu64, id);
         IOVEC_SET_STRING(iov[n_iov++], id_field);
 
-        m = alloca(strlen("MESSAGE=audit-") + DECIMAL_STR_MAX(int) + strlen(": ") + strlen(p) + 1);
-        sprintf(m, "MESSAGE=audit-%i: %s", type, p);
+        m = alloca(strlen("MESSAGE=<audit-") + DECIMAL_STR_MAX(int) + strlen("> ") + strlen(p) + 1);
+        sprintf(m, "MESSAGE=<audit-%i> %s", type, p);
         IOVEC_SET_STRING(iov[n_iov++], m);
 
         z = n_iov;
@@ -547,15 +543,13 @@ int server_open_audit(Server *s) {
         }
 
         r = sd_event_add_io(s->event, &s->audit_event_source, s->audit_fd, EPOLLIN, process_datagram, s);
-        if (r < 0) {
-                log_error("Failed to add audit fd to event loop: %s", strerror(-r));
-                return r;
-        }
+        if (r < 0)
+                return log_error_errno(r, "Failed to add audit fd to event loop: %m");
 
         /* We are listening now, try to enable audit */
         r = enable_audit(s->audit_fd, true);
         if (r < 0)
-                log_warning("Failed to issue audit enable call: %s", strerror(-r));
+                log_warning_errno(r, "Failed to issue audit enable call: %m");
 
         return 0;
 }