nspawn: make check-pointer-deref clean

Add the needed assert changes to make the code clean
for the new check-pointer-deref script.
This commit is contained in:
Michael Vogt
2026-03-30 13:36:00 +02:00
parent 69d54d5213
commit f3c49a597f
3 changed files with 11 additions and 4 deletions
-1
View File
@@ -2982,7 +2982,6 @@ if spatch.found()
'src/journal/',
'src/libsystemd/',
'src/network/',
'src/nspawn/',
'src/shared/',
# libc/ has no assert() or systemd-headers so leave it
'src/libc/',
+8 -3
View File
@@ -1489,6 +1489,8 @@ static int oci_resources(const char *name, sd_json_variant *v, sd_json_dispatch_
static bool sysctl_key_valid(const char *s) {
bool dot = true;
POINTER_MAY_BE_NULL(s);
/* Note that we are a bit stricter here than in systemd-sysctl, as that inherited semantics from the old sysctl
* tool, which were really weird (as it swaps / and . in both ways) */
@@ -1546,7 +1548,6 @@ static int oci_sysctl(const char *name, sd_json_variant *v, sd_json_dispatch_fla
#if HAVE_SECCOMP
static int oci_seccomp_action_from_string(const char *name, uint32_t *ret) {
static const struct {
const char *name;
uint32_t action;
@@ -1563,6 +1564,8 @@ static int oci_seccomp_action_from_string(const char *name, uint32_t *ret) {
* here */
};
assert(ret);
FOREACH_ELEMENT(i, table)
if (streq_ptr(name, i->name)) {
*ret = i->action;
@@ -1573,7 +1576,6 @@ static int oci_seccomp_action_from_string(const char *name, uint32_t *ret) {
}
static int oci_seccomp_arch_from_string(const char *name, uint32_t *ret) {
static const struct {
const char *name;
uint32_t arch;
@@ -1605,6 +1607,8 @@ static int oci_seccomp_arch_from_string(const char *name, uint32_t *ret) {
{ "SCMP_ARCH_X86_64", SCMP_ARCH_X86_64 },
};
assert(ret);
FOREACH_ELEMENT(i, table)
if (streq_ptr(i->name, name)) {
*ret = i->arch;
@@ -1615,7 +1619,6 @@ static int oci_seccomp_arch_from_string(const char *name, uint32_t *ret) {
}
static int oci_seccomp_compare_from_string(const char *name, enum scmp_compare *ret) {
static const struct {
const char *name;
enum scmp_compare op;
@@ -1629,6 +1632,8 @@ static int oci_seccomp_compare_from_string(const char *name, enum scmp_compare *
{ "SCMP_CMP_MASKED_EQ", SCMP_CMP_MASKED_EQ },
};
assert(ret);
FOREACH_ELEMENT(i, table)
if (streq_ptr(i->name, name)) {
*ret = i->op;
+3
View File
@@ -2981,6 +2981,7 @@ static int wait_for_container(PidRef *pid, ContainerStatus *container) {
int r;
assert(pidref_is_set(pid));
assert(container);
r = pidref_wait_for_terminate(pid, &status);
if (r < 0)
@@ -4723,6 +4724,8 @@ static int nspawn_dispatch_notify_fd(sd_event_source *source, int fd, uint32_t r
static int setup_notify_parent(sd_event *event, int fd, PidRef *inner_child_pid, sd_event_source **notify_event_source) {
int r;
assert(notify_event_source);
if (fd < 0)
return 0;