sd_bus_slot_set_destroy_callback(3): incorrect return type for sd_bus_destroy_t
systemd version the issue has been seen with
systemd 255 (255.4-1ubuntu8.17)
Used distribution
Ubuntu 24.04.5 LTS
Linux kernel version used
7.0.0-34-generic
CPU architectures issue was seen on
x86_64
Component
other
Expected behaviour you didn't see
The sd_bus_slot_set_destroy_callback(3) documentation should declare sd_bus_destroy_t with the same function signature as the public headers:
typedef void (*sd_bus_destroy_t)(void *userdata);Code written according to the documentation should compile when passed as a destroy callback.
Unexpected behaviour you saw
The man page currently documents sd_bus_destroy_t as:
typedef int (*sd_bus_destroy_t)(void *userdata);However, the public headers define sd_bus_destroy_t through _sd_destroy_t, whose return type is void.
As a result, code written according to the man page fails to compile. For example, a C++ non-capturing lambda returning int is converted to:
int (*)(void *)but sd_bus_slot_set_destroy_callback() expects:
sd_bus_destroy_t
aka void (*)(void *)The documentation source in the current upstream main branch also
contains the incorrect int return type.
Steps to reproduce the problem
The man page currently documents sd_bus_destroy_t as:
typedef int (*sd_bus_destroy_t)(void *userdata);However, the public headers define sd_bus_destroy_t through _sd_destroy_t, whose return type is void.
As a result, code written according to the man page fails to compile. For example, a C++ non-capturing lambda returning int is converted to:
int (*)(void *)but sd_bus_slot_set_destroy_callback() expects:
sd_bus_destroy_t
aka void (*)(void *)The documentation source in the current upstream main branch also
contains the incorrect int return type.
Additional program output to the terminal or log subsystem illustrating the issue
error: invalid user-defined conversion from
‘...::<lambda(void*)>’
to ‘sd_bus_destroy_t’ {aka ‘void (*)(void*)’}
note: candidate is:
‘constexpr ...::<lambda(void*)>::operator int (*)(void*)() const’
note: no known conversion from
‘int (*)(void*)’
to
‘sd_bus_destroy_t’ {aka ‘void (*)(void*)’}
The current upstream documentation source contains:
<funcdef>typedef int (*<function>sd_bus_destroy_t</function>)</funcdef>
while the public headers define:
typedef _sd_destroy_t sd_bus_destroy_t;
with _sd_destroy_t using a void return type.Source: systemd/systemd