summaryrefslogtreecommitdiffstats
path: root/src/libsystemd/sd-bus/bus-objects.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2020-04-28 17:04:08 +0200
committerLennart Poettering <lennart@poettering.net>2020-05-13 16:57:44 +0200
commit491ce161037a11b52abec74eeb6c8cfa512ef1fb (patch)
tree689b670678f8bf274b8d1143080c09532eb67bb1 /src/libsystemd/sd-bus/bus-objects.c
parentresolved: port to stat_inode_unmodified() (diff)
downloadsystemd-491ce161037a11b52abec74eeb6c8cfa512ef1fb.tar.xz
systemd-491ce161037a11b52abec74eeb6c8cfa512ef1fb.zip
sd-bus: introduce new SD_BUS_VTABLE_ABSOLUTE_OFFSET vtable flag
When set, the offset specified for the vtable entry is passed to the handler as-is, and is not added to the userdata pointer. This is useful in case methods/properties are mixed on the same vtable, that expect to operate relative to some object in memory and that expect pointers to absolute memory, or that just want a number passed.
Diffstat (limited to 'src/libsystemd/sd-bus/bus-objects.c')
-rw-r--r--src/libsystemd/sd-bus/bus-objects.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/libsystemd/sd-bus/bus-objects.c b/src/libsystemd/sd-bus/bus-objects.c
index ad66d634d7..6abac8822c 100644
--- a/src/libsystemd/sd-bus/bus-objects.c
+++ b/src/libsystemd/sd-bus/bus-objects.c
@@ -56,7 +56,7 @@ static int node_vtable_get_userdata(
static void *vtable_method_convert_userdata(const sd_bus_vtable *p, void *u) {
assert(p);
- if (!u)
+ if (!u || FLAGS_SET(p->flags, SD_BUS_VTABLE_ABSOLUTE_OFFSET))
return SIZE_TO_PTR(p->x.method.offset); /* don't add offset on NULL, to make ubsan happy */
return (uint8_t*) u + p->x.method.offset;
@@ -65,7 +65,7 @@ static void *vtable_method_convert_userdata(const sd_bus_vtable *p, void *u) {
static void *vtable_property_convert_userdata(const sd_bus_vtable *p, void *u) {
assert(p);
- if (!u)
+ if (!u || FLAGS_SET(p->flags, SD_BUS_VTABLE_ABSOLUTE_OFFSET))
return SIZE_TO_PTR(p->x.property.offset); /* as above */
return (uint8_t*) u + p->x.property.offset;