core: 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:
@@ -2978,7 +2978,6 @@ if spatch.found()
|
||||
# Remove directories from this list as they are cleaned up.
|
||||
coccinelle_exclude = [
|
||||
'src/basic/',
|
||||
'src/core/',
|
||||
'src/libsystemd/',
|
||||
'src/shared/',
|
||||
# libc/ has no assert() or systemd-headers so leave it
|
||||
|
||||
@@ -661,6 +661,8 @@ static int attach_custom_bpf_progs(Unit *u, const char *path, int attach_type, S
|
||||
int r;
|
||||
|
||||
assert(u);
|
||||
assert(set);
|
||||
assert(set_installed);
|
||||
|
||||
set_clear(*set_installed);
|
||||
r = set_ensure_allocated(set_installed, &bpf_program_hash_ops);
|
||||
|
||||
@@ -313,6 +313,8 @@ static int unit_compare_memory_limit(Unit *u, const char *property_name, uint64_
|
||||
* - ret_kernel_value will contain the actual value presented by the kernel. */
|
||||
|
||||
assert(u);
|
||||
assert(ret_unit_value);
|
||||
assert(ret_kernel_value);
|
||||
|
||||
/* The root slice doesn't have any controller files, so we can't compare anything. */
|
||||
if (unit_has_name(u, SPECIAL_ROOT_SLICE))
|
||||
@@ -3189,6 +3191,8 @@ static int cg_bpf_mask_supported(CGroupMask *ret) {
|
||||
CGroupMask mask = 0;
|
||||
int r;
|
||||
|
||||
assert(ret);
|
||||
|
||||
/* BPF-based firewall, device access control, and pinned foreign prog */
|
||||
if (bpf_program_supported() > 0)
|
||||
mask |= CGROUP_MASK_BPF_FIREWALL |
|
||||
|
||||
@@ -240,6 +240,8 @@ int parse_emergency_action(
|
||||
|
||||
EmergencyAction x;
|
||||
|
||||
assert(ret);
|
||||
|
||||
x = emergency_action_from_string(value);
|
||||
if (x < 0)
|
||||
return -EINVAL;
|
||||
|
||||
@@ -510,6 +510,8 @@ JobType job_type_collapse(JobType t, Unit *u) {
|
||||
int job_type_merge_and_collapse(JobType *a, JobType b, Unit *u) {
|
||||
JobType t;
|
||||
|
||||
assert(a);
|
||||
|
||||
t = job_type_lookup_merge(*a, b);
|
||||
if (t < 0)
|
||||
return -EEXIST;
|
||||
@@ -1523,6 +1525,11 @@ void job_add_to_gc_queue(Job *j) {
|
||||
}
|
||||
|
||||
static int job_compare_id(Job * const *a, Job * const *b) {
|
||||
assert(a);
|
||||
assert(b);
|
||||
assert(*a);
|
||||
assert(*b);
|
||||
|
||||
return CMP((*a)->id, (*b)->id);
|
||||
}
|
||||
|
||||
|
||||
@@ -88,6 +88,8 @@ static int parse_socket_protocol(const char *s) {
|
||||
int parse_crash_chvt(const char *value, int *data) {
|
||||
int b;
|
||||
|
||||
assert(data);
|
||||
|
||||
if (safe_atoi(value, data) >= 0)
|
||||
return 0;
|
||||
|
||||
@@ -107,6 +109,8 @@ int parse_confirm_spawn(const char *value, char **console) {
|
||||
char *s;
|
||||
int r;
|
||||
|
||||
assert(console);
|
||||
|
||||
r = value ? parse_boolean(value) : 1;
|
||||
if (r == 0) {
|
||||
*console = NULL;
|
||||
@@ -565,6 +569,8 @@ static int patch_var_run(
|
||||
const char *e;
|
||||
char *z;
|
||||
|
||||
assert(path);
|
||||
|
||||
e = path_startswith(*path, "/var/run/");
|
||||
if (!e)
|
||||
return 0;
|
||||
|
||||
@@ -1982,6 +1982,8 @@ Manager* manager_reloading_start(Manager *m) {
|
||||
}
|
||||
|
||||
void manager_reloading_stopp(Manager **m) {
|
||||
assert(m);
|
||||
|
||||
if (*m) {
|
||||
assert((*m)->n_reloading > 0);
|
||||
(*m)->n_reloading--;
|
||||
|
||||
@@ -2003,6 +2003,8 @@ static int mount_get_timeout(Unit *u, usec_t *timeout) {
|
||||
usec_t t;
|
||||
int r;
|
||||
|
||||
assert(timeout);
|
||||
|
||||
if (!m->timer_event_source)
|
||||
return 0;
|
||||
|
||||
|
||||
@@ -931,6 +931,7 @@ static int activation_details_path_deserialize(const char *key, const char *valu
|
||||
|
||||
assert(key);
|
||||
assert(value);
|
||||
POINTER_MAY_BE_NULL(details);
|
||||
|
||||
if (!details || !*details)
|
||||
return -EINVAL;
|
||||
|
||||
@@ -483,6 +483,8 @@ static int scope_get_timeout(Unit *u, usec_t *timeout) {
|
||||
usec_t t;
|
||||
int r;
|
||||
|
||||
assert(timeout);
|
||||
|
||||
if (!s->timer_event_source)
|
||||
return 0;
|
||||
|
||||
|
||||
@@ -26,6 +26,9 @@ static int fdopen_unlocked_at(int dfd, const char *dir, const char *name, int *s
|
||||
int fd, r;
|
||||
FILE *f;
|
||||
|
||||
assert(status);
|
||||
assert(ret_file);
|
||||
|
||||
fd = openat(dfd, name, O_RDONLY|O_CLOEXEC);
|
||||
if (fd < 0) {
|
||||
if (*status == 0)
|
||||
|
||||
@@ -3525,6 +3525,8 @@ static int socket_get_timeout(Unit *u, usec_t *timeout) {
|
||||
usec_t t;
|
||||
int r;
|
||||
|
||||
assert(timeout);
|
||||
|
||||
if (!s->timer_event_source)
|
||||
return 0;
|
||||
|
||||
|
||||
@@ -1427,6 +1427,8 @@ static int swap_get_timeout(Unit *u, usec_t *timeout) {
|
||||
usec_t t;
|
||||
int r;
|
||||
|
||||
assert(timeout);
|
||||
|
||||
if (!s->timer_event_source)
|
||||
return 0;
|
||||
|
||||
|
||||
@@ -940,6 +940,7 @@ static int activation_details_timer_deserialize(const char *key, const char *val
|
||||
|
||||
assert(key);
|
||||
assert(value);
|
||||
POINTER_MAY_BE_NULL(details);
|
||||
|
||||
if (!details || !*details)
|
||||
return -EINVAL;
|
||||
|
||||
@@ -6377,6 +6377,7 @@ int unit_clean(Unit *u, ExecCleanMask mask) {
|
||||
|
||||
int unit_can_clean(Unit *u, ExecCleanMask *ret) {
|
||||
assert(u);
|
||||
assert(ret);
|
||||
|
||||
if (!UNIT_VTABLE(u)->clean ||
|
||||
u->load_state != UNIT_LOADED) {
|
||||
|
||||
@@ -781,6 +781,9 @@ static int set_credential_build_json(sd_json_variant **ret, const char *name, vo
|
||||
int unit_exec_context_build_json(sd_json_variant **ret, const char *name, void *userdata) {
|
||||
Unit *u = ASSERT_PTR(userdata);
|
||||
ExecContext *c = unit_get_exec_context(u);
|
||||
|
||||
assert(ret);
|
||||
|
||||
if (!c) {
|
||||
*ret = NULL;
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user