From: Zbigniew Jędrzejewski-Szmek Date: Wed, 15 Jun 2022 08:25:08 +0000 (+0200) Subject: sd-bus: use assert_return() in public function sd_bus_message_dump X-Git-Tag: v252-rc1~751^2~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=628f7b1e706907d2520b3e51878bce3c787613c5;p=thirdparty%2Fsystemd.git sd-bus: use assert_return() in public function sd_bus_message_dump Also, document that NULL is allowed. --- diff --git a/man/sd_bus_message_dump.xml b/man/sd_bus_message_dump.xml index eac0541ca4a..83a4a4e31ab 100644 --- a/man/sd_bus_message_dump.xml +++ b/man/sd_bus_message_dump.xml @@ -44,9 +44,10 @@ Description The sd_bus_message_dump() function writes a textual representation of the - message m to the stream f. This function is intended to be - used for debugging purposes, and the output is neither stable nor designed to be machine readable. - + message m to the stream f. If f is + NULL, standard output (stdio) 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. The flags parameter may be used to modify the output. With SD_BUS_MESSAGE_DUMP_WITH_HEADER, a header that specifies the message type and flags diff --git a/src/libsystemd/sd-bus/bus-dump.c b/src/libsystemd/sd-bus/bus-dump.c index d67a170a2d9..73939d8f7a7 100644 --- a/src/libsystemd/sd-bus/bus-dump.c +++ b/src/libsystemd/sd-bus/bus-dump.c @@ -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; diff --git a/src/systemd/sd-bus.h b/src/systemd/sd-bus.h index 12168a22a2b..74bc56b4274 100644 --- a/src/systemd/sd-bus.h +++ b/src/systemd/sd-bus.h @@ -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 */