chiark / gitweb /
remove unused includes
[elogind.git] / src / libsystemd / sd-bus / bus-dump.c
index b57ac41e055cdf19210d1d9259df14b1ad66c812..4bc896549a464eded5e0035baa5f3d94b34aff8c 100644 (file)
@@ -22,8 +22,8 @@
 #include "util.h"
 #include "capability.h"
 #include "strv.h"
-#include "audit.h"
 #include "macro.h"
+#include "cap-list.h"
 
 #include "bus-message.h"
 #include "bus-internal.h"
@@ -68,7 +68,7 @@ int bus_message_dump(sd_bus_message *m, FILE *f, unsigned flags) {
 
         if (flags & BUS_MESSAGE_DUMP_WITH_HEADER) {
                 fprintf(f,
-                        "%s%s%s Type=%s%s%s  Endian=%c  Flags=%u  Version=%u  Priority=%lli",
+                        "%s%s%s Type=%s%s%s  Endian=%c  Flags=%u  Version=%u  Priority=%"PRIi64,
                         m->header->type == SD_BUS_MESSAGE_METHOD_ERROR ? ansi_highlight_red() :
                         m->header->type == SD_BUS_MESSAGE_METHOD_RETURN ? ansi_highlight_green() :
                         m->header->type != SD_BUS_MESSAGE_SIGNAL ? ansi_highlight() : "", draw_special_char(DRAW_TRIANGULAR_BULLET), ansi_highlight_off(),
@@ -76,7 +76,7 @@ int bus_message_dump(sd_bus_message *m, FILE *f, unsigned flags) {
                         m->header->endian,
                         m->header->flags,
                         m->header->version,
-                        (long long) m->priority);
+                        m->priority);
 
                 /* Display synthetic message serial number in a more readable
                  * format than (uint32_t) -1 */
@@ -125,13 +125,18 @@ int bus_message_dump(sd_bus_message *m, FILE *f, unsigned flags) {
         }
 
         r = sd_bus_message_rewind(m, !(flags & BUS_MESSAGE_DUMP_SUBTREE_ONLY));
-        if (r < 0) {
-                log_error_errno(r, "Failed to rewind: %m");
-                return r;
-        }
+        if (r < 0)
+                return log_error_errno(r, "Failed to rewind: %m");
+
+        if (!(flags & BUS_MESSAGE_DUMP_SUBTREE_ONLY)) {
+                _cleanup_free_ char *prefix = NULL;
 
-        if (!(flags & BUS_MESSAGE_DUMP_SUBTREE_ONLY))
-                fprintf(f, "%sMESSAGE \"%s\" {\n", indent(0, flags), strempty(m->root_container.signature));
+                prefix = indent(0, flags);
+                if (!prefix)
+                        return log_oom();
+
+                fprintf(f, "%sMESSAGE \"%s\" {\n", prefix, strempty(m->root_container.signature));
+        }
 
         for (;;) {
                 _cleanup_free_ char *prefix = NULL;
@@ -151,20 +156,16 @@ int bus_message_dump(sd_bus_message *m, FILE *f, unsigned flags) {
                 } basic;
 
                 r = sd_bus_message_peek_type(m, &type, &contents);
-                if (r < 0) {
-                        log_error_errno(r, "Failed to peek type: %m");
-                        return r;
-                }
+                if (r < 0)
+                        return log_error_errno(r, "Failed to peek type: %m");
 
                 if (r == 0) {
                         if (level <= 1)
                                 break;
 
                         r = sd_bus_message_exit_container(m);
-                        if (r < 0) {
-                                log_error_errno(r, "Failed to exit container: %m");
-                                return r;
-                        }
+                        if (r < 0)
+                                return log_error_errno(r, "Failed to exit container: %m");
 
                         level--;
 
@@ -182,10 +183,8 @@ int bus_message_dump(sd_bus_message *m, FILE *f, unsigned flags) {
 
                 if (bus_type_is_container(type) > 0) {
                         r = sd_bus_message_enter_container(m, type, contents);
-                        if (r < 0) {
-                                log_error_errno(r, "Failed to enter container: %m");
-                                return r;
-                        }
+                        if (r < 0)
+                                return log_error_errno(r, "Failed to enter container: %m");
 
                         if (type == SD_BUS_TYPE_ARRAY)
                                 fprintf(f, "%sARRAY \"%s\" {\n", prefix, contents);
@@ -202,10 +201,8 @@ int bus_message_dump(sd_bus_message *m, FILE *f, unsigned flags) {
                 }
 
                 r = sd_bus_message_read_basic(m, type, &basic);
-                if (r < 0) {
-                        log_error_errno(r, "Failed to get basic: %m");
-                        return r;
-                }
+                if (r < 0)
+                        return log_error_errno(r, "Failed to get basic: %m");
 
                 assert(r > 0);
 
@@ -268,8 +265,15 @@ int bus_message_dump(sd_bus_message *m, FILE *f, unsigned flags) {
                 }
         }
 
-        if (!(flags & BUS_MESSAGE_DUMP_SUBTREE_ONLY))
-                fprintf(f, "%s};\n\n", indent(0, flags));
+        if (!(flags & BUS_MESSAGE_DUMP_SUBTREE_ONLY)) {
+                _cleanup_free_ char *prefix = NULL;
+
+                prefix = indent(0, flags);
+                if (!prefix)
+                        return log_oom();
+
+                fprintf(f, "%s};\n\n", prefix);
+        }
 
         return 0;
 }
@@ -300,15 +304,13 @@ static void dump_capabilities(
 
         for (;;) {
                 if (r > 0) {
-                        _cleanup_cap_free_charp_ char *t;
 
                         if (n > 0)
                                 fputc(' ', f);
                         if (n % 4 == 3)
                                 fprintf(f, terse ? "\n          " : "\n        ");
 
-                        t = cap_to_name(i);
-                        fprintf(f, "%s", t);
+                        fprintf(f, "%s", strna(capability_to_name(i)));
                         n++;
                 }
 
@@ -351,17 +353,15 @@ int bus_creds_dump(sd_bus_creds *c, FILE *f, bool terse) {
                 color = ansi_highlight();
 
                 off = ansi_highlight_off();
-                suffix = strappenda(off, "\n");
+                suffix = strjoina(off, "\n");
         }
 
         if (c->mask & SD_BUS_CREDS_PID)
                 fprintf(f, "%sPID=%s"PID_FMT"%s", prefix, color, c->pid, suffix);
-        if (c->mask & SD_BUS_CREDS_PID_STARTTIME)
-                fprintf(f, "%sPIDStartTime=%s"USEC_FMT"%s", prefix, color, c->pid_starttime, suffix);
         if (c->mask & SD_BUS_CREDS_TID)
                 fprintf(f, "%sTID=%s"PID_FMT"%s", prefix, color, c->tid, suffix);
 
-        if (terse && ((c->mask & (SD_BUS_CREDS_PID|SD_BUS_CREDS_PID_STARTTIME|SD_BUS_CREDS_TID))))
+        if (terse && ((c->mask & (SD_BUS_CREDS_PID|SD_BUS_CREDS_TID))))
                 fputs("\n", f);
 
         if (c->mask & SD_BUS_CREDS_UID)
@@ -432,16 +432,16 @@ int bus_creds_dump(sd_bus_creds *c, FILE *f, bool terse) {
 
         if (c->mask & SD_BUS_CREDS_CGROUP)
                 fprintf(f, "%sCGroup=%s%s%s", prefix, color, c->cgroup, suffix);
-        sd_bus_creds_get_unit(c, &u);
+        (void) sd_bus_creds_get_unit(c, &u);
         if (u)
                 fprintf(f, "%sUnit=%s%s%s", prefix, color, u, suffix);
-        sd_bus_creds_get_user_unit(c, &uu);
+        (void) sd_bus_creds_get_user_unit(c, &uu);
         if (uu)
                 fprintf(f, "%sUserUnit=%s%s%s", prefix, color, uu, suffix);
-        sd_bus_creds_get_slice(c, &sl);
+        (void) sd_bus_creds_get_slice(c, &sl);
         if (sl)
                 fprintf(f, "%sSlice=%s%s%s", prefix, color, sl, suffix);
-        sd_bus_creds_get_session(c, &s);
+        (void) sd_bus_creds_get_session(c, &s);
         if (s)
                 fprintf(f, "%sSession=%s%s%s", prefix, color, s, suffix);