1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2024-12-22 13:33:56 +03:00

sd-bus: use assert_return() in public function sd_bus_message_dump

Also, document that NULL is allowed.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2022-06-15 10:25:08 +02:00
parent 7e922b0584
commit 628f7b1e70
3 changed files with 8 additions and 5 deletions

View File

@ -44,9 +44,10 @@
<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

View 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;

View 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 */