[systemd-devel] [WIP][PATCH 3/3] sd-bus: why not allow entering containers with unknown contents?

Tom Gundersen teg at jklm.no
Sun Oct 20 14:59:55 PDT 2013


---
 src/machine/machinectl.c | 21 ++++++++++++++++-----
 1 file changed, 16 insertions(+), 5 deletions(-)

diff --git a/src/machine/machinectl.c b/src/machine/machinectl.c
index ba0ceb7..5731247 100644
--- a/src/machine/machinectl.c
+++ b/src/machine/machinectl.c
@@ -334,6 +334,21 @@ static int print_property(const char *name, sd_bus_message *reply) {
         return 0;
 }
 
+static int sd_bus_message_enter_unknown_container(sd_bus_message *message, char type) {
+        const char *contents;
+        int r;
+
+        r = sd_bus_message_peek_type(reply, NULL, &contents);
+        if (r < 0)
+                return r;
+
+        r = sd_bus_message_enter_contanire(reply, type, contents);
+        if (r < 0)
+                return r;
+
+        return 0;
+}
+
 static int show_one(const char *verb, sd_bus *bus, const char *path, bool show_properties, bool *new_line) {
         _cleanup_bus_message_unref_ sd_bus_message *reply = NULL;
         _cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
@@ -378,11 +393,7 @@ static int show_one(const char *verb, sd_bus *bus, const char *path, bool show_p
                 if (r < 0)
                         goto fail;
 
-                r = sd_bus_message_peek_type(reply, NULL, &contents);
-                if (r < 0)
-                        goto fail;
-
-                r = sd_bus_message_enter_container(reply, SD_BUS_TYPE_VARIANT, contents);
+                r = sd_bus_message_enter_unknown_container(reply, SD_BUS_TYPE_VARIANT);
                 if (r < 0)
                         goto fail;
 
-- 
1.8.4.1



More information about the systemd-devel mailing list