mirror of
https://github.com/systemd/systemd.git
synced 2024-12-26 03:22:00 +03:00
nspawn: use ASSERT_PTR() more
This commit is contained in:
parent
cb4e5d5155
commit
797424245e
@ -90,7 +90,7 @@ static int oci_unsupported(const char *name, JsonVariant *v, JsonDispatchFlags f
|
||||
}
|
||||
|
||||
static int oci_terminal(const char *name, JsonVariant *v, JsonDispatchFlags flags, void *userdata) {
|
||||
Settings *s = userdata;
|
||||
Settings *s = ASSERT_PTR(userdata);
|
||||
|
||||
/* If not specified, or set to true, we'll default to either an interactive or a read-only
|
||||
* console. If specified as false, we'll forcibly move to "pipe" mode though. */
|
||||
@ -115,6 +115,7 @@ static int oci_console_dimension(const char *name, JsonVariant *variant, JsonDis
|
||||
}
|
||||
|
||||
static int oci_console_size(const char *name, JsonVariant *v, JsonDispatchFlags flags, void *userdata) {
|
||||
Settings *s = ASSERT_PTR(userdata);
|
||||
|
||||
static const JsonDispatch table[] = {
|
||||
{ "height", JSON_VARIANT_UNSIGNED, oci_console_dimension, offsetof(Settings, console_height), JSON_MANDATORY },
|
||||
@ -122,7 +123,7 @@ static int oci_console_size(const char *name, JsonVariant *v, JsonDispatchFlags
|
||||
{}
|
||||
};
|
||||
|
||||
return json_dispatch(v, table, oci_unexpected, flags, userdata);
|
||||
return json_dispatch(v, table, oci_unexpected, flags, s);
|
||||
}
|
||||
|
||||
static int oci_absolute_path(const char *name, JsonVariant *v, JsonDispatchFlags flags, void *userdata) {
|
||||
@ -186,9 +187,8 @@ static int oci_args(const char *name, JsonVariant *v, JsonDispatchFlags flags, v
|
||||
|
||||
static int oci_rlimit_type(const char *name, JsonVariant *v, JsonDispatchFlags flags, void *userdata) {
|
||||
const char *z;
|
||||
int t, *type = userdata;
|
||||
|
||||
assert_se(type);
|
||||
int *type = ASSERT_PTR(userdata);
|
||||
int t;
|
||||
|
||||
z = startswith(json_variant_string(v), "RLIMIT_");
|
||||
if (!z)
|
||||
@ -206,7 +206,8 @@ static int oci_rlimit_type(const char *name, JsonVariant *v, JsonDispatchFlags f
|
||||
}
|
||||
|
||||
static int oci_rlimit_value(const char *name, JsonVariant *v, JsonDispatchFlags flags, void *userdata) {
|
||||
rlim_t z, *value = ASSERT_PTR(userdata);
|
||||
rlim_t *value = ASSERT_PTR(userdata);
|
||||
rlim_t z;
|
||||
|
||||
if (json_variant_is_negative(v))
|
||||
z = RLIM_INFINITY;
|
||||
@ -227,7 +228,6 @@ static int oci_rlimit_value(const char *name, JsonVariant *v, JsonDispatchFlags
|
||||
}
|
||||
|
||||
static int oci_rlimits(const char *name, JsonVariant *v, JsonDispatchFlags flags, void *userdata) {
|
||||
|
||||
Settings *s = ASSERT_PTR(userdata);
|
||||
JsonVariant *e;
|
||||
int r;
|
||||
@ -276,7 +276,8 @@ static int oci_rlimits(const char *name, JsonVariant *v, JsonDispatchFlags flags
|
||||
}
|
||||
|
||||
static int oci_capability_array(const char *name, JsonVariant *v, JsonDispatchFlags flags, void *userdata) {
|
||||
uint64_t *mask = userdata, m = 0;
|
||||
uint64_t *mask = ASSERT_PTR(userdata);
|
||||
uint64_t m = 0;
|
||||
JsonVariant *e;
|
||||
|
||||
JSON_VARIANT_ARRAY_FOREACH(e, v) {
|
||||
@ -347,10 +348,10 @@ static int oci_oom_score_adj(const char *name, JsonVariant *v, JsonDispatchFlags
|
||||
}
|
||||
|
||||
static int oci_uid_gid(const char *name, JsonVariant *v, JsonDispatchFlags flags, void *userdata) {
|
||||
uid_t *uid = userdata, u;
|
||||
uid_t *uid = ASSERT_PTR(userdata);
|
||||
uid_t u;
|
||||
uint64_t k;
|
||||
|
||||
assert(uid);
|
||||
assert_cc(sizeof(uid_t) == sizeof(gid_t));
|
||||
|
||||
k = json_variant_unsigned(v);
|
||||
@ -395,6 +396,7 @@ static int oci_supplementary_gids(const char *name, JsonVariant *v, JsonDispatch
|
||||
}
|
||||
|
||||
static int oci_user(const char *name, JsonVariant *v, JsonDispatchFlags flags, void *userdata) {
|
||||
|
||||
static const JsonDispatch table[] = {
|
||||
{ "uid", JSON_VARIANT_UNSIGNED, oci_uid_gid, offsetof(Settings, uid), JSON_MANDATORY },
|
||||
{ "gid", JSON_VARIANT_UNSIGNED, oci_uid_gid, offsetof(Settings, gid), JSON_MANDATORY },
|
||||
@ -427,7 +429,7 @@ static int oci_process(const char *name, JsonVariant *v, JsonDispatchFlags flags
|
||||
}
|
||||
|
||||
static int oci_root(const char *name, JsonVariant *v, JsonDispatchFlags flags, void *userdata) {
|
||||
Settings *s = userdata;
|
||||
Settings *s = ASSERT_PTR(userdata);
|
||||
int r;
|
||||
|
||||
static const JsonDispatch table[] = {
|
||||
@ -611,13 +613,11 @@ static int oci_namespace_type(const char *name, JsonVariant *v, JsonDispatchFlag
|
||||
}
|
||||
|
||||
static int oci_namespaces(const char *name, JsonVariant *v, JsonDispatchFlags flags, void *userdata) {
|
||||
Settings *s = userdata;
|
||||
Settings *s = ASSERT_PTR(userdata);
|
||||
unsigned long n = 0;
|
||||
JsonVariant *e;
|
||||
int r;
|
||||
|
||||
assert_se(s);
|
||||
|
||||
JSON_VARIANT_ARRAY_FOREACH(e, v) {
|
||||
|
||||
struct namespace_data {
|
||||
@ -675,10 +675,10 @@ static int oci_namespaces(const char *name, JsonVariant *v, JsonDispatchFlags fl
|
||||
}
|
||||
|
||||
static int oci_uid_gid_range(const char *name, JsonVariant *v, JsonDispatchFlags flags, void *userdata) {
|
||||
uid_t *uid = userdata, u;
|
||||
uid_t *uid = ASSERT_PTR(userdata);
|
||||
uid_t u;
|
||||
uint64_t k;
|
||||
|
||||
assert(uid);
|
||||
assert_cc(sizeof(uid_t) == sizeof(gid_t));
|
||||
|
||||
/* This is very much like oci_uid_gid(), except the checks are a bit different, as this is a UID range rather
|
||||
@ -777,11 +777,9 @@ static int oci_device_type(const char *name, JsonVariant *v, JsonDispatchFlags f
|
||||
}
|
||||
|
||||
static int oci_device_major(const char *name, JsonVariant *v, JsonDispatchFlags flags, void *userdata) {
|
||||
unsigned *u = userdata;
|
||||
unsigned *u = ASSERT_PTR(userdata);
|
||||
uint64_t k;
|
||||
|
||||
assert_se(u);
|
||||
|
||||
k = json_variant_unsigned(v);
|
||||
if (!DEVICE_MAJOR_VALID(k))
|
||||
return json_log(v, flags, SYNTHETIC_ERRNO(ERANGE),
|
||||
@ -792,11 +790,9 @@ static int oci_device_major(const char *name, JsonVariant *v, JsonDispatchFlags
|
||||
}
|
||||
|
||||
static int oci_device_minor(const char *name, JsonVariant *v, JsonDispatchFlags flags, void *userdata) {
|
||||
unsigned *u = userdata;
|
||||
unsigned *u = ASSERT_PTR(userdata);
|
||||
uint64_t k;
|
||||
|
||||
assert_se(u);
|
||||
|
||||
k = json_variant_unsigned(v);
|
||||
if (!DEVICE_MINOR_VALID(k))
|
||||
return json_log(v, flags, SYNTHETIC_ERRNO(ERANGE),
|
||||
@ -807,11 +803,10 @@ static int oci_device_minor(const char *name, JsonVariant *v, JsonDispatchFlags
|
||||
}
|
||||
|
||||
static int oci_device_file_mode(const char *name, JsonVariant *v, JsonDispatchFlags flags, void *userdata) {
|
||||
mode_t *mode = userdata, m;
|
||||
mode_t *mode = ASSERT_PTR(userdata);
|
||||
mode_t m;
|
||||
uint64_t k;
|
||||
|
||||
assert(mode);
|
||||
|
||||
k = json_variant_unsigned(v);
|
||||
m = (mode_t) k;
|
||||
|
||||
@ -931,7 +926,7 @@ static int oci_cgroups_path(const char *name, JsonVariant *v, JsonDispatchFlags
|
||||
}
|
||||
|
||||
static int oci_cgroup_device_type(const char *name, JsonVariant *v, JsonDispatchFlags flags, void *userdata) {
|
||||
mode_t *mode = userdata;
|
||||
mode_t *mode = ASSERT_PTR(userdata);
|
||||
const char *n;
|
||||
|
||||
assert_se(n = json_variant_string(v));
|
||||
@ -958,7 +953,7 @@ struct device_data {
|
||||
};
|
||||
|
||||
static int oci_cgroup_device_access(const char *name, JsonVariant *v, JsonDispatchFlags flags, void *userdata) {
|
||||
struct device_data *d = userdata;
|
||||
struct device_data *d = ASSERT_PTR(userdata);
|
||||
bool r = false, w = false, m = false;
|
||||
const char *s;
|
||||
size_t i;
|
||||
@ -984,7 +979,6 @@ static int oci_cgroup_device_access(const char *name, JsonVariant *v, JsonDispat
|
||||
}
|
||||
|
||||
static int oci_cgroup_devices(const char *name, JsonVariant *v, JsonDispatchFlags flags, void *userdata) {
|
||||
|
||||
_cleanup_free_ struct device_data *list = NULL;
|
||||
Settings *s = ASSERT_PTR(userdata);
|
||||
size_t n_list = 0, i;
|
||||
@ -1187,7 +1181,7 @@ static int oci_cgroup_memory(const char *name, JsonVariant *v, JsonDispatchFlags
|
||||
{}
|
||||
};
|
||||
|
||||
Settings *s = userdata;
|
||||
Settings *s = ASSERT_PTR(userdata);
|
||||
int r;
|
||||
|
||||
r = json_dispatch(v, table, oci_unexpected, flags, &data);
|
||||
@ -1303,7 +1297,7 @@ static int oci_cgroup_cpu(const char *name, JsonVariant *v, JsonDispatchFlags fl
|
||||
.period = UINT64_MAX,
|
||||
};
|
||||
|
||||
Settings *s = userdata;
|
||||
Settings *s = ASSERT_PTR(userdata);
|
||||
int r;
|
||||
|
||||
r = json_dispatch(v, table, oci_unexpected, flags, &data);
|
||||
@ -2031,7 +2025,7 @@ static int oci_linux(const char *name, JsonVariant *v, JsonDispatchFlags flags,
|
||||
}
|
||||
|
||||
static int oci_hook_timeout(const char *name, JsonVariant *v, JsonDispatchFlags flags, void *userdata) {
|
||||
usec_t *u = userdata;
|
||||
usec_t *u = ASSERT_PTR(userdata);
|
||||
uint64_t k;
|
||||
|
||||
k = json_variant_unsigned(v);
|
||||
|
Loading…
Reference in New Issue
Block a user