diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2017-06-03 05:41:17 -0400 |
---|---|---|
committer | Martin Pitt <martinpitt@users.noreply.github.com> | 2017-06-03 11:41:17 +0200 |
commit | 3e7d14d78c4d15ec7789299216cbf5c58e61547b (patch) | |
tree | 5ae13d61f097fe0aef6bf6ec040db2f88a3e6ef3 /src/libsystemd/sd-bus/bus-control.c | |
parent | tests: skip test_exec_inaccessiblepaths_proc when inaccessible dir is unavail... (diff) | |
download | systemd-3e7d14d78c4d15ec7789299216cbf5c58e61547b.tar.gz systemd-3e7d14d78c4d15ec7789299216cbf5c58e61547b.tar.bz2 systemd-3e7d14d78c4d15ec7789299216cbf5c58e61547b.zip |
sd-bus: silence format warnings in kdbus code (#6072)
The code is mostly correct, but gcc is trying to outsmart us, and emits a
warning for a "llu vs lu" mismatch, even though they are the same size (on alpha):
src/libsystemd/sd-bus/bus-control.c: In function ‘kernel_get_list’:
src/libsystemd/sd-bus/bus-control.c:267:42: error: format ‘%llu’ expects argument of type ‘long long unsigned int’, but argument 3 has type ‘__u64 {aka long unsigned int}’ [-Werror=format=]
if (asprintf(&n, ":1.%llu", name->id) < 0) {
^
src/libsystemd/sd-bus/bus-control.c: In function ‘bus_get_name_creds_kdbus’:
src/libsystemd/sd-bus/bus-control.c:714:47: error: format ‘%llu’ expects argument of type ‘long long unsigned int’, but argument 3 has type ‘__u64 {aka long unsigned int}’ [-Werror=format=]
if (asprintf(&c->unique_name, ":1.%llu", conn_info->id) < 0) {
^
This is hard to work around properly, because kdbus.h uses __u64 which is
defined-differently-despite-being-the-same-size then uint64_t. Thus the simple
solution of using %PRIu64 fails on amd64:
src/libsystemd/sd-bus/bus-control.c:714:47: error: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 3 has type ‘__u64 {aka long long unsigned int}’ [-Werror=format=]
if (asprintf(&c->unique_name, ":1.%"PRIu64, conn_info->id) < 0) {
^~~~~~
Let's just avoid the whole issue for now by silencing the warning.
After the next release, we should just get rid of the kdbus code.
Fixes #5561.
Diffstat (limited to 'src/libsystemd/sd-bus/bus-control.c')
-rw-r--r-- | src/libsystemd/sd-bus/bus-control.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/libsystemd/sd-bus/bus-control.c b/src/libsystemd/sd-bus/bus-control.c index 9e58ffbd8..303ae0f23 100644 --- a/src/libsystemd/sd-bus/bus-control.c +++ b/src/libsystemd/sd-bus/bus-control.c @@ -264,10 +264,13 @@ static int kernel_get_list(sd_bus *bus, uint64_t flags, char ***x) { if ((flags & KDBUS_LIST_UNIQUE) && name->id != previous_id && !(name->flags & KDBUS_HELLO_ACTIVATOR)) { char *n; +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wformat" if (asprintf(&n, ":1.%llu", name->id) < 0) { r = -ENOMEM; goto fail; } +#pragma GCC diagnostic pop r = strv_consume(x, n); if (r < 0) @@ -711,10 +714,13 @@ int bus_get_name_creds_kdbus( } if (mask & SD_BUS_CREDS_UNIQUE_NAME) { +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wformat" if (asprintf(&c->unique_name, ":1.%llu", conn_info->id) < 0) { r = -ENOMEM; goto fail; } +#pragma GCC diagnostic pop c->mask |= SD_BUS_CREDS_UNIQUE_NAME; } |