diff options
author | Luca Boccassi <bluca@debian.org> | 2023-10-06 23:02:09 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-06 23:02:09 +0200 |
commit | a5e6d2fdf59f68e44fb0e0a263f32bc1fd543684 (patch) | |
tree | d0d137c0af372c803e9cd820e9fe0a6b5299bdb7 | |
parent | Merge pull request #29440 from evelikov/more-auto-entries (diff) | |
parent | basic/macro: add comment explaining DEFINE_TRIVIAL_DESTRUCTOR() (diff) | |
download | systemd-a5e6d2fdf59f68e44fb0e0a263f32bc1fd543684.tar.xz systemd-a5e6d2fdf59f68e44fb0e0a263f32bc1fd543684.zip |
Merge pull request #29475 from keszybz/remove-wrapper-functions
Remove unnecessary wrapper functions
-rw-r--r-- | src/basic/macro.h | 2 | ||||
-rw-r--r-- | src/libsystemd/sd-bus/fuzz-bus-match.c | 4 | ||||
-rw-r--r-- | src/nspawn/nspawn-oci.c | 20 |
3 files changed, 11 insertions, 15 deletions
diff --git a/src/basic/macro.h b/src/basic/macro.h index 0c99d68db2..7f650d0719 100644 --- a/src/basic/macro.h +++ b/src/basic/macro.h @@ -310,6 +310,8 @@ static inline int __coverity_check_and_return__(int condition) { #define FOREACH_ARRAY(i, array, num) \ _FOREACH_ARRAY(i, array, num, UNIQ_T(m, UNIQ), UNIQ_T(end, UNIQ)) +/* A wrapper for 'func' to return void. + * Only useful when a void-returning function is required by some API. */ #define DEFINE_TRIVIAL_DESTRUCTOR(name, type, func) \ static inline void name(type *p) { \ func(p); \ diff --git a/src/libsystemd/sd-bus/fuzz-bus-match.c b/src/libsystemd/sd-bus/fuzz-bus-match.c index b79494d888..f7f12746e5 100644 --- a/src/libsystemd/sd-bus/fuzz-bus-match.c +++ b/src/libsystemd/sd-bus/fuzz-bus-match.c @@ -9,8 +9,6 @@ #include "fuzz.h" #include "memstream-util.h" -DEFINE_TRIVIAL_DESTRUCTOR(bus_match_donep, struct bus_match_node, bus_match_free); - int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { _cleanup_(memstream_done) MemStream m = {}; _cleanup_(sd_bus_unrefp) sd_bus *bus = NULL; @@ -28,7 +26,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { r = sd_bus_new(&bus); assert_se(r >= 0); - _cleanup_(bus_match_donep) struct bus_match_node root = { + _cleanup_(bus_match_free) struct bus_match_node root = { .type = BUS_MATCH_ROOT, }; diff --git a/src/nspawn/nspawn-oci.c b/src/nspawn/nspawn-oci.c index 5bdfebde78..8075dd6829 100644 --- a/src/nspawn/nspawn-oci.c +++ b/src/nspawn/nspawn-oci.c @@ -509,14 +509,14 @@ typedef struct oci_mount_data { } oci_mount_data; static void oci_mount_data_done(oci_mount_data *data) { + assert(data); + free(data->destination); free(data->source); free(data->type); strv_free(data->options); } -DEFINE_TRIVIAL_DESTRUCTOR(oci_mount_data_donep, oci_mount_data, oci_mount_data_done); - static int oci_mounts(const char *name, JsonVariant *v, JsonDispatchFlags flags, void *userdata) { Settings *s = ASSERT_PTR(userdata); JsonVariant *e; @@ -532,7 +532,7 @@ static int oci_mounts(const char *name, JsonVariant *v, JsonDispatchFlags flags, }; _cleanup_free_ char *joined_options = NULL; - _cleanup_(oci_mount_data_donep) oci_mount_data data = {}; + _cleanup_(oci_mount_data_done) oci_mount_data data = {}; CustomMount *m; r = json_dispatch(e, table, oci_unexpected, flags, &data); @@ -614,14 +614,12 @@ struct namespace_data { char *path; }; -static void namespace_data_done(struct namespace_data *p) { - assert(p); +static void namespace_data_done(struct namespace_data *data) { + assert(data); - free(p->path); + free(data->path); } -DEFINE_TRIVIAL_DESTRUCTOR(namespace_data_donep, struct namespace_data, namespace_data_done); - static int oci_namespaces(const char *name, JsonVariant *v, JsonDispatchFlags flags, void *userdata) { Settings *s = ASSERT_PTR(userdata); unsigned long n = 0; @@ -629,7 +627,7 @@ static int oci_namespaces(const char *name, JsonVariant *v, JsonDispatchFlags fl int r; JSON_VARIANT_ARRAY_FOREACH(e, v) { - _cleanup_(namespace_data_donep) struct namespace_data data = {}; + _cleanup_(namespace_data_done) struct namespace_data data = {}; static const JsonDispatch table[] = { { "type", JSON_VARIANT_STRING, oci_namespace_type, offsetof(struct namespace_data, type), JSON_MANDATORY }, @@ -1744,8 +1742,6 @@ static void syscall_rule_done(struct syscall_rule *rule) { free(rule->arguments); }; -DEFINE_TRIVIAL_DESTRUCTOR(syscall_rule_donep, struct syscall_rule, syscall_rule_done); - static int oci_seccomp_action(const char *name, JsonVariant *v, JsonDispatchFlags flags, void *userdata) { uint32_t *action = ASSERT_PTR(userdata); int r; @@ -1829,7 +1825,7 @@ static int oci_seccomp_syscalls(const char *name, JsonVariant *v, JsonDispatchFl { "args", JSON_VARIANT_ARRAY, oci_seccomp_args, 0, 0 }, {} }; - _cleanup_(syscall_rule_donep) struct syscall_rule rule = { + _cleanup_(syscall_rule_done) struct syscall_rule rule = { .action = UINT32_MAX, }; |