1
0
mirror of https://github.com/systemd/systemd.git synced 2025-02-03 17:47:28 +03:00

nspawn: drop unnecessary wrapper functions

The naming was confused: suffix 'p' means that the function takes a pointer to
the type that the wrapped function takes. (E.g., a char**, for a wrapped function
taking a char*.)  But DEFINE_TRIVIAL_DESTRUCTOR() just changes the return type.

Also add one more assert for consistency.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2023-10-05 18:58:55 +02:00
parent 15461b7f19
commit f95c9f46e2

View File

@ -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,
};