From 02f2d2b33bec3a3d9dc85a87e25bb056cc0fc0f8 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 28 Jul 2021 20:38:31 +0200 Subject: [PATCH 1/2] sd-bus: fix indentation in macros We use multiples of 8 spaces indentation in our C code, do it here too. --- src/systemd/sd-bus-vtable.h | 74 ++++++++++++++++++------------------- 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/src/systemd/sd-bus-vtable.h b/src/systemd/sd-bus-vtable.h index 35c942b16cc..438c651cb28 100644 --- a/src/systemd/sd-bus-vtable.h +++ b/src/systemd/sd-bus-vtable.h @@ -106,11 +106,11 @@ struct sd_bus_vtable { .type = _SD_BUS_VTABLE_START, \ .flags = _flags, \ .x = { \ - .start = { \ - .element_size = sizeof(sd_bus_vtable), \ - .features = _SD_BUS_VTABLE_PARAM_NAMES, \ - .vtable_format_reference = &sd_bus_object_vtable_format, \ - }, \ + .start = { \ + .element_size = sizeof(sd_bus_vtable), \ + .features = _SD_BUS_VTABLE_PARAM_NAMES, \ + .vtable_format_reference = &sd_bus_object_vtable_format, \ + }, \ }, \ } @@ -122,14 +122,14 @@ struct sd_bus_vtable { .type = _SD_BUS_VTABLE_METHOD, \ .flags = _flags, \ .x = { \ - .method = { \ - .member = _member, \ - .signature = _signature, \ - .result = _result, \ - .handler = _handler, \ - .offset = _offset, \ - .names = _in_names _out_names, \ - }, \ + .method = { \ + .member = _member, \ + .signature = _signature, \ + .result = _result, \ + .handler = _handler, \ + .offset = _offset, \ + .names = _in_names _out_names, \ + }, \ }, \ } #define SD_BUS_METHOD_WITH_OFFSET(_member, _signature, _result, _handler, _offset, _flags) \ @@ -144,14 +144,14 @@ struct sd_bus_vtable { .type = _SD_BUS_VTABLE_SIGNAL, \ .flags = _flags, \ .x = { \ - .signal = { \ - .member = _member, \ - .signature = _signature, \ - .names = _out_names, \ - }, \ + .signal = { \ + .member = _member, \ + .signature = _signature, \ + .names = _out_names, \ + }, \ }, \ - } -#define SD_BUS_SIGNAL(_member, _signature, _flags) \ + } +#define SD_BUS_SIGNAL(_member, _signature, _flags) \ SD_BUS_SIGNAL_WITH_NAMES(_member, _signature, "", _flags) #define SD_BUS_PROPERTY(_member, _signature, _get, _offset, _flags) \ @@ -159,13 +159,13 @@ struct sd_bus_vtable { .type = _SD_BUS_VTABLE_PROPERTY, \ .flags = _flags, \ .x = { \ - .property = { \ - .member = _member, \ - .signature = _signature, \ - .get = _get, \ - .set = NULL, \ - .offset = _offset, \ - }, \ + .property = { \ + .member = _member, \ + .signature = _signature, \ + .get = _get, \ + .set = NULL, \ + .offset = _offset, \ + }, \ }, \ } @@ -174,13 +174,13 @@ struct sd_bus_vtable { .type = _SD_BUS_VTABLE_WRITABLE_PROPERTY, \ .flags = _flags, \ .x = { \ - .property = { \ - .member = _member, \ - .signature = _signature, \ - .get = _get, \ - .set = _set, \ - .offset = _offset, \ - }, \ + .property = { \ + .member = _member, \ + .signature = _signature, \ + .get = _get, \ + .set = _set, \ + .offset = _offset, \ + }, \ }, \ } @@ -189,9 +189,9 @@ struct sd_bus_vtable { .type = _SD_BUS_VTABLE_END, \ .flags = 0, \ .x = { \ - .end = { \ - .reserved = 0, \ - }, \ + .end = { \ + .reserved = 0, \ + }, \ }, \ } From 0c4801738e83cb9c4a5e6fc5b24ed914a9496512 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 28 Jul 2021 20:44:49 +0200 Subject: [PATCH 2/2] sd-bus: add brief inline comment explaining the "reserved" field in the bus vtable structure Follow-up for: #20253 --- src/systemd/sd-bus-vtable.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/systemd/sd-bus-vtable.h b/src/systemd/sd-bus-vtable.h index 438c651cb28..8b316fac5ac 100644 --- a/src/systemd/sd-bus-vtable.h +++ b/src/systemd/sd-bus-vtable.h @@ -76,7 +76,10 @@ struct sd_bus_vtable { const unsigned *vtable_format_reference; } start; struct { - size_t reserved; + /* This field exists only to make sure we have something to initialize in + * SD_BUS_VTABLE_END in a way that is both compatible with pedantic versions of C and + * C++. It's unused otherwise. */ + size_t _reserved; } end; struct { const char *member; @@ -190,7 +193,7 @@ struct sd_bus_vtable { .flags = 0, \ .x = { \ .end = { \ - .reserved = 0, \ + ._reserved = 0, \ }, \ }, \ }