]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
sd-bus: use assert_return() in public function sd_bus_message_dump
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 15 Jun 2022 08:25:08 +0000 (10:25 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 30 Jun 2022 08:55:39 +0000 (10:55 +0200)
Also, document that NULL is allowed.

man/sd_bus_message_dump.xml
src/libsystemd/sd-bus/bus-dump.c
src/systemd/sd-bus.h

index eac0541ca4acdf385b1332bc142dd9b64d936160..83a4a4e31ab46f81eef9dbdb9c1ee8a81d5fbb39 100644 (file)
     <title>Description</title>
 
     <para>The <function>sd_bus_message_dump()</function> function writes a textual representation of the
-    message <parameter>m</parameter> to the stream <parameter>f</parameter>. This function is intended to be
-    used for debugging purposes, and the output is neither stable nor designed to be machine readable.
-    </para>
+    message <parameter>m</parameter> to the stream <parameter>f</parameter>. If <parameter>f</parameter> is
+    <constant>NULL</constant>, standard output (<constant>stdio</constant>) will be used. This function is
+    intended to be used for debugging purposes, and the output is neither stable nor designed to be machine
+    readable.</para>
 
     <para>The <parameter>flags</parameter> parameter may be used to modify the output. With
     <constant>SD_BUS_MESSAGE_DUMP_WITH_HEADER</constant>, a header that specifies the message type and flags
index d67a170a2d9bb7bcd4581fd728ff660805f69414..73939d8f7a7ec6e555099aa125c4a5beb918e1d0 100644 (file)
@@ -50,7 +50,8 @@ _public_ int sd_bus_message_dump(sd_bus_message *m, FILE *f, uint64_t flags) {
         unsigned level = 1;
         int r;
 
-        assert(m);
+        assert_return(m, -EINVAL);
+        assert_return((flags & ~_SD_BUS_MESSAGE_DUMP_KNOWN_FLAGS) == 0, -EINVAL);
 
         if (!f)
                 f = stdout;
index 12168a22a2b449276fd8c666fb120c4c743ecc0b..74bc56b4274d356fb0605a381d1cf53f122ea935 100644 (file)
@@ -102,7 +102,8 @@ __extension__ enum {
 
 __extension__ enum {
         SD_BUS_MESSAGE_DUMP_WITH_HEADER  = 1ULL << 0,
-        SD_BUS_MESSAGE_DUMP_SUBTREE_ONLY = 1ULL << 1
+        SD_BUS_MESSAGE_DUMP_SUBTREE_ONLY = 1ULL << 1,
+        _SD_BUS_MESSAGE_DUMP_KNOWN_FLAGS = SD_BUS_MESSAGE_DUMP_WITH_HEADER | SD_BUS_MESSAGE_DUMP_SUBTREE_ONLY
 };
 
 /* Callbacks */