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
+10
View File
@@ -848,6 +848,8 @@ int set_ensure_allocated(Set **s, const struct hash_ops *hash_ops) {
int hashmap_ensure_put(Hashmap **h, const struct hash_ops *hash_ops, const void *key, void *value) {
int r;
assert(h);
r = hashmap_ensure_allocated(h, hash_ops);
if (r < 0)
return r;
@@ -858,6 +860,8 @@ int hashmap_ensure_put(Hashmap **h, const struct hash_ops *hash_ops, const void
int ordered_hashmap_ensure_put(OrderedHashmap **h, const struct hash_ops *hash_ops, const void *key, void *value) {
int r;
assert(h);
r = ordered_hashmap_ensure_allocated(h, hash_ops);
if (r < 0)
return r;
@@ -868,6 +872,8 @@ int ordered_hashmap_ensure_put(OrderedHashmap **h, const struct hash_ops *hash_o
int ordered_hashmap_ensure_replace(OrderedHashmap **h, const struct hash_ops *hash_ops, const void *key, void *value) {
int r;
assert(h);
r = ordered_hashmap_ensure_allocated(h, hash_ops);
if (r < 0)
return r;
@@ -878,6 +884,8 @@ int ordered_hashmap_ensure_replace(OrderedHashmap **h, const struct hash_ops *ha
int hashmap_ensure_replace(Hashmap **h, const struct hash_ops *hash_ops, const void *key, void *value) {
int r;
assert(h);
r = hashmap_ensure_allocated(h, hash_ops);
if (r < 0)
return r;
@@ -1283,6 +1291,8 @@ int set_put(Set *s, const void *key) {
int set_ensure_put(Set **s, const struct hash_ops *hash_ops, const void *key) {
int r;
assert(s);
r = set_ensure_allocated(s, hash_ops);
if (r < 0)
return r;