many: fix remaining check-pointer-deref issues
The updated parsing_hacks.h file uncovered a bunch of extra things that the check-pointer-deref coccinelle script flags. This commit fixes them to make the tree check-pointer-deref clean.
This commit is contained in:
@@ -195,6 +195,8 @@ static int find_build_dir_binary(const char *fn, char **ret) {
|
||||
|
||||
static int find_environment_binary(const char *fn, const char **ret) {
|
||||
|
||||
assert(ret);
|
||||
|
||||
/* If a path such as /usr/lib/systemd/systemd-foobar is specified, then this will check for an
|
||||
* environment variable SYSTEMD_FOOBAR_PATH and return it if set. */
|
||||
|
||||
|
||||
@@ -1256,6 +1256,8 @@ bool cg_needs_escape(const char *p) {
|
||||
int cg_escape(const char *p, char **ret) {
|
||||
_cleanup_free_ char *n = NULL;
|
||||
|
||||
assert(ret);
|
||||
|
||||
/* This implements very minimal escaping for names to be used as file names in the cgroup tree: any
|
||||
* name which might conflict with a kernel name or is prefixed with '_' is prefixed with a '_'. That
|
||||
* way, when reading cgroup names it is sufficient to remove a single prefixing underscore if there
|
||||
@@ -1652,6 +1654,8 @@ int cg_mask_supported_subtree(const char *root, CGroupMask *ret) {
|
||||
CGroupMask mask;
|
||||
int r;
|
||||
|
||||
assert(ret);
|
||||
|
||||
/* Determines the mask of supported cgroup controllers. Only includes controllers we can make sense of and that
|
||||
* are actually accessible. Only covers real controllers, i.e. not the CGROUP_CONTROLLER_BPF_xyz
|
||||
* pseudo-controllers. */
|
||||
|
||||
@@ -1370,6 +1370,8 @@ int read_timestamp_file(const char *fn, usec_t *ret) {
|
||||
uint64_t t;
|
||||
int r;
|
||||
|
||||
assert(ret);
|
||||
|
||||
r = read_one_line_file(fn, &ln);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
@@ -1853,6 +1853,8 @@ int set_consume(Set *s, void *value) {
|
||||
int hashmap_put_strdup_full(Hashmap **h, const struct hash_ops *hash_ops, const char *k, const char *v) {
|
||||
int r;
|
||||
|
||||
assert(h);
|
||||
|
||||
r = hashmap_ensure_allocated(h, hash_ops);
|
||||
if (r < 0)
|
||||
return r;
|
||||
@@ -2197,6 +2199,8 @@ int _hashmap_dump_keys_sorted(HashmapBase *h, void ***ret, size_t *ret_n) {
|
||||
size_t n;
|
||||
int r;
|
||||
|
||||
assert(ret);
|
||||
|
||||
r = _hashmap_dump_entries_sorted(h, &entries, &n);
|
||||
if (r < 0)
|
||||
return r;
|
||||
@@ -2216,6 +2220,8 @@ int _hashmap_dump_sorted(HashmapBase *h, void ***ret, size_t *ret_n) {
|
||||
size_t n;
|
||||
int r;
|
||||
|
||||
assert(ret);
|
||||
|
||||
r = _hashmap_dump_entries_sorted(h, &entries, &n);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
@@ -1076,6 +1076,8 @@ int path_split_prefix_filename(const char *path, char **ret_dir, char **ret_file
|
||||
const char *c, *next = NULL;
|
||||
int r;
|
||||
|
||||
POINTER_MAY_BE_NULL(path);
|
||||
|
||||
/* Split the path into dir prefix/filename pair. Returns:
|
||||
*
|
||||
* -EINVAL → if the path is not valid
|
||||
|
||||
@@ -667,6 +667,7 @@ char* strip_tab_ansi(char **ibuf, size_t *_isz, size_t highlight[2]) {
|
||||
|
||||
assert(ibuf);
|
||||
assert(*ibuf);
|
||||
POINTER_MAY_BE_NULL(_isz);
|
||||
|
||||
/* This does three things:
|
||||
*
|
||||
|
||||
@@ -1463,6 +1463,8 @@ int getttyname_harder(int fd, char **ret) {
|
||||
_cleanup_free_ char *s = NULL;
|
||||
int r;
|
||||
|
||||
assert(ret);
|
||||
|
||||
r = getttyname_malloc(fd, &s);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
@@ -39,6 +39,8 @@ static int parse_alloc_uid(const char *path, const char *name, const char *t, ui
|
||||
#endif
|
||||
|
||||
int read_login_defs(UGIDAllocationRange *ret_defs, const char *path, const char *root) {
|
||||
assert(ret_defs);
|
||||
|
||||
#if ENABLE_COMPAT_MUTABLE_UID_BOUNDARIES
|
||||
_cleanup_fclose_ FILE *f = NULL;
|
||||
UGIDAllocationRange defs;
|
||||
|
||||
@@ -345,6 +345,7 @@ int unit_name_unescape(const char *f, char **ret) {
|
||||
char *t;
|
||||
|
||||
assert(f);
|
||||
assert(ret);
|
||||
|
||||
r = strdup(f);
|
||||
if (!r)
|
||||
@@ -547,6 +548,8 @@ int unit_name_hash_long(const char *name, char **ret) {
|
||||
le64_t h;
|
||||
size_t len;
|
||||
|
||||
assert(ret);
|
||||
|
||||
if (strlen(name) < UNIT_NAME_MAX)
|
||||
return -EMSGSIZE;
|
||||
|
||||
|
||||
@@ -284,6 +284,9 @@ int utf8_to_ascii(const char *str, char replacement_char, char **ret) {
|
||||
/* Convert to a string that has only ASCII chars, replacing anything that is not ASCII
|
||||
* by replacement_char. */
|
||||
|
||||
assert(str);
|
||||
assert(ret);
|
||||
|
||||
_cleanup_free_ char *ans = new(char, strlen(str) + 1);
|
||||
if (!ans)
|
||||
return -ENOMEM;
|
||||
|
||||
Reference in New Issue
Block a user