]> git.ipfire.org Git - thirdparty/systemd.git/commit
hashmap: fix iterators to not skip entries 197/head
authorDavid Herrmann <dh.herrmann@gmail.com>
Sun, 14 Jun 2015 14:51:35 +0000 (16:51 +0200)
committerDavid Herrmann <dh.herrmann@gmail.com>
Sun, 14 Jun 2015 14:56:02 +0000 (16:56 +0200)
commit8927b1dad2d4a7330174cb924090b4635a2547fb
treeaa730ee2822e083e988f7621fcafefd65006b844
parentaa75494ad5cdf7bede947212ad8c8356d78580fa
hashmap: fix iterators to not skip entries

Currently, the HASHMAP iterators stop at the first NULL entry in a
hashmap. This is non-obvious and breaks users like sd-device, which
legitimately store NULL values in a hashmap.

Fix all the iterators by taking a pointer to the value storage, instead of
returning it. The iterators now return a boolean that tells whether the
end of the list was reached.

Current users of HASHMAP_FOREACH() are *NOT* changed to explicitly check
for NULL. If it turns out, there were users that inserted NULL into
hashmaps, but didn't properly check for it during iteration, then we
really want to find those and fix them.
src/basic/fdset.c
src/basic/hashmap.c
src/basic/hashmap.h
src/basic/ordered-set.h
src/basic/set.h
src/libsystemd/sd-bus/bus-track.c
src/libsystemd/sd-device/sd-device.c
src/libsystemd/sd-hwdb/sd-hwdb.c
src/test/test-hashmap-plain.c