basic: make check-pointer-deref clean

Add the needed assert changes to make the code clean
for the new check-pointer-deref script.

Note that for `_cmp()` functions its a bit of a question
if we want `assert()` or `POINTER_MAY_BE_NULL()` here. The
former is more correct but it adds a (small) runtime hit. If
we use POINTER_MAY_BE_NULL() it is compiled out but strictly
speaking it is wrong (so at least we would need a comment).
This commit is contained in:
Michael Vogt
2026-03-31 18:30:40 +02:00
parent 1692d51eb2
commit 18e70eec2f
30 changed files with 146 additions and 3 deletions
+14
View File
@@ -587,6 +587,9 @@ int strv_push_with_size(char ***l, size_t *n, char *value) {
* If n is not NULL, the size after the push will be returned.
* If value is empty, no action is taken and *n is not set. */
assert(l);
POINTER_MAY_BE_NULL(n);
if (!value)
return 0;
@@ -615,6 +618,8 @@ int strv_push_pair(char ***l, char *a, char *b) {
char **c;
size_t n;
assert(l);
if (!a && !b)
return 0;
@@ -828,6 +833,9 @@ char** strv_remove(char **l, const char *s) {
}
bool strv_overlap(char * const *a, char * const *b) {
POINTER_MAY_BE_NULL(a);
POINTER_MAY_BE_NULL(b);
STRV_FOREACH(i, a)
if (strv_contains(b, *i))
return true;
@@ -836,6 +844,9 @@ bool strv_overlap(char * const *a, char * const *b) {
}
static int str_compare(char * const *a, char * const *b) {
assert(a);
assert(b);
return strcmp(*a, *b);
}
@@ -862,6 +873,9 @@ char** strv_sort_uniq(char **l) {
int strv_compare(char * const *a, char * const *b) {
int r;
POINTER_MAY_BE_NULL(a);
POINTER_MAY_BE_NULL(b);
if (strv_isempty(a)) {
if (strv_isempty(b))
return 0;