From 6b7af82122d13264ebbbcd99e71f2d9da71552b6 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Thu, 18 May 2017 18:24:17 +0200 Subject: [PATCH 1/2] man: extend documentation on sd_bus_add_match a bit() Explain briefly how the concept of "sd_bus_slot" works. This recently came up on the mailing list, hence let's document this for the next time. --- man/sd_bus_add_match.xml | 43 +++++++++++++++++++++++----------------- 1 file changed, 25 insertions(+), 18 deletions(-) diff --git a/man/sd_bus_add_match.xml b/man/sd_bus_add_match.xml index 8bcf7164a0c..2014141ae34 100644 --- a/man/sd_bus_add_match.xml +++ b/man/sd_bus_add_match.xml @@ -73,26 +73,34 @@ Description - sd_bus_add_match() adds a match rule used to dispatch - incoming messages. The syntax of the rule passed in - match is described in the - D-Bus Specification. + sd_bus_add_match() installs a match rule for incoming messages received on the specified bus + connection object bus. The syntax of the match rule expression passed in + match is described in the D-Bus Specification. The specified handler + function callback is called for eaching incoming message matching the specified + expression, the userdata parameter is passed as-is to the callback function. - The message m passed to the callback is only - borrowed, that is, the callback should not call - sd_bus_message_unref3 - on it. If the callback wants to hold on to the message beyond the lifetime - of the callback, it needs to call - sd_bus_message_ref3 - to create a new reference. + On success, and if non-NULL, the slot return parameter will be set to + a slot object that may be used as a reference to the installed match, and may be utilized to remove it again at a + later time with + sd_bus_slot_unref3. If + specified as NULL the lifetime of the match is bound to the lifetime of the bus object itself, and the match + cannot be removed independently. - If an error occurs during the callback invocation, the callback should - return a negative error number. If it wants other callbacks that match the - same rule to be called, it should return 0. Otherwise it should return a + The message m passed to the callback is only borrowed, that is, the callback should not + call sd_bus_message_unref3 on + it. If the callback wants to hold on to the message beyond the lifetime of the callback, it needs to call + sd_bus_message_ref3 to create + a new reference. + + + + If an error occurs during the callback invocation, the callback should return a negative error number. If it + wants other callbacks that match the same rule to be called, it should return 0. Otherwise it should return a positive integer. @@ -101,9 +109,8 @@ Return Value - On success, sd_bus_add_match() returns 0 or a - positive integer. On failure, it returns a negative errno-style error - code. + On success, sd_bus_add_match() returns 0 or a positive integer. On failure, it returns a + negative errno-style error code. @@ -112,7 +119,7 @@ systemd1, - sd-bus3, + sd-bus3 From 86a48fb6f732c30812f3d29e5564d64037aff42f Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Thu, 18 May 2017 18:25:02 +0200 Subject: [PATCH 2/2] udev: turn off -Wformat-nonliteral for one safe case c20e6de897b2378bc3f936e1e265d2d2e2450a73 introduced a format string as variable, but didn't turn off -Wformat-nonliteral warnings on it, thus breaking the build. Let's fix that, by simply turning off the warning in this case, as we know it's safe. --- src/udev/udev-builtin-net_id.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/udev/udev-builtin-net_id.c b/src/udev/udev-builtin-net_id.c index f385fe95658..46eb6114ff5 100644 --- a/src/udev/udev-builtin-net_id.c +++ b/src/udev/udev-builtin-net_id.c @@ -389,8 +389,12 @@ static int names_platform(struct udev_device *dev, struct netnames *names, bool * eg. "/sys/devices/platform/HISI00C2:00"); * The Vendor (3 or 4 char), followed by hexdecimal model number : instance id. */ + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wformat-nonliteral" if (sscanf(syspath, pattern, vendor, &model, &instance, ðid) != 4) return -EINVAL; +#pragma GCC diagnostic pop if (!in_charset(vendor, validchars)) return -ENOENT;