chiark / gitweb /
Introduce cleanup functions for cap_free
[elogind.git] / src / libsystemd-bus / bus-dump.c
index 469f7baaf586c9460c2e13a62741fc3693c6445e..78e7597ed540bca227f9fb752b2be0e6e485f4be 100644 (file)
@@ -19,8 +19,6 @@
   along with systemd; If not, see <http://www.gnu.org/licenses/>.
 ***/
 
-#include <sys/capability.h>
-
 #include "util.h"
 #include "capability.h"
 #include "strv.h"
@@ -56,18 +54,24 @@ int bus_message_dump(sd_bus_message *m, FILE *f, bool with_header) {
 
         if (with_header) {
                 fprintf(f,
-                        "%s%s%sType=%s%s%s  Endian=%c  Flags=%u  Version=%u  Serial=%u ",
+                        "%s%s%sType=%s%s%s  Endian=%c  Flags=%u  Version=%u",
                         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(),
                         ansi_highlight(), bus_message_type_to_string(m->header->type), ansi_highlight_off(),
                         m->header->endian,
                         m->header->flags,
-                        m->header->version,
-                        BUS_MESSAGE_SERIAL(m));
+                        m->header->version);
+
+                /* Display synthetic message serial number in a more readable
+                 * format than (uint32_t) -1 */
+                if (BUS_MESSAGE_COOKIE(m) == 0xFFFFFFFFULL)
+                        fprintf(f, " Cookie=-1");
+                else
+                        fprintf(f, " Cookie=%lu", (unsigned long) BUS_MESSAGE_COOKIE(m));
 
-                if (m->reply_serial != 0)
-                        fprintf(f, "  ReplySerial=%u", m->reply_serial);
+                if (m->reply_cookie != 0)
+                        fprintf(f, "  ReplyCookie=%lu", (unsigned long) m->reply_cookie);
 
                 fputs("\n", f);
 
@@ -111,7 +115,7 @@ int bus_message_dump(sd_bus_message *m, FILE *f, bool with_header) {
 
         fprintf(f, "  MESSAGE \"%s\" {\n", strempty(m->root_container.signature));
 
-        for(;;) {
+        for (;;) {
                 _cleanup_free_ char *prefix = NULL;
                 const char *contents = NULL;
                 char type;
@@ -194,7 +198,7 @@ int bus_message_dump(sd_bus_message *m, FILE *f, bool with_header) {
                         break;
 
                 case SD_BUS_TYPE_BOOLEAN:
-                        fprintf(f, "%sBOOLEAN %s%s%s;\n", prefix, ansi_highlight(), yes_no(basic.i), ansi_highlight_off());
+                        fprintf(f, "%sBOOLEAN %s%s%s;\n", prefix, ansi_highlight(), true_false(basic.i), ansi_highlight_off());
                         break;
 
                 case SD_BUS_TYPE_INT16:
@@ -275,12 +279,15 @@ static void dump_capabilities(
 
         for (;;) {
                 if (r > 0) {
+                        _cleanup_cap_free_charp_ char *t;
+
                         if (n > 0)
                                 fputc(' ', f);
                         if (n % 4 == 3)
                                 fputs("\n          ", f);
 
-                        fputs(cap_to_name(i), f);
+                        t = cap_to_name(i);
+                        fprintf(f, "%s", t);
                         n++;
                 }