[systemd-devel] [PATCH] [RFC] libsystemd-bus: true/false instead of yes/no in msg dump

Lukasz Skalski l.skalski at partner.samsung.com
Tue Dec 17 01:55:28 PST 2013


Due to this patch, message dump (for message which includes boolean
type) is more consistent with dbus-send (which display true/false
instead of yes/no for boolean). It's only simple 'cosmetics change'.

** For dbus-send **

dbus-send --system --dest=org.freedesktop.DBus --type=method_call --print-reply / org.freedesktop.DBus.NameHasOwner string:org.freedesktop.login1

method return sender=org.freedesktop.DBus -> dest=:1.97 reply_serial=2
   boolean true

** For libsystemd-bus (without this patch) **

‣ Type=method_call  Endian=l  Flags=0  Version=2 Serial=8
  Destination=org.freedesktop.DBus  Path=/org/freedesktop/DBus  Interface=org.freedesktop.DBus  Member=NameHasOwner
  MESSAGE "s" {
  	STRING "org.freedesktop.login1";
  };

‣ Type=method_return  Endian=l  Flags=1  Version=2 Serial=51  ReplySerial=8
  Sender=:1.59  Destination=:1.67
  UniqueName=:1.59  WellKnownNames={org.freedesktop.DBus}
  MESSAGE "b" {
  	BOOLEAN yes;
  };

For me true/false seems to be better readable than yes/no for BOOLEAN.
---
 src/libsystemd-bus/bus-dump.c | 2 +-
 src/shared/util.h             | 4 ++++
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/libsystemd-bus/bus-dump.c b/src/libsystemd-bus/bus-dump.c
index ddad418..7b61479 100644
--- a/src/libsystemd-bus/bus-dump.c
+++ b/src/libsystemd-bus/bus-dump.c
@@ -200,7 +200,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:
diff --git a/src/shared/util.h b/src/shared/util.h
index dd51e89..1d17826 100644
--- a/src/shared/util.h
+++ b/src/shared/util.h
@@ -92,6 +92,10 @@ static inline const char* yes_no(bool b) {
         return b ? "yes" : "no";
 }
 
+static inline const char* true_false(bool b) {
+        return b ? "true" : "false";
+}
+
 static inline const char* strempty(const char *s) {
         return s ? s : "";
 }
-- 
1.8.3.2



More information about the systemd-devel mailing list