chiark / gitweb /
hashmap: fix iterators to not skip entries
authorDavid Herrmann <dh.herrmann@gmail.com>
Sun, 14 Jun 2015 14:51:35 +0000 (16:51 +0200)
committerSven Eden <yamakuzure@gmx.net>
Tue, 14 Mar 2017 09:02:58 +0000 (10:02 +0100)
commit545407b3b250edd0a05e314a0b5cf73cdb5a74fa
tree76e0a43f447b105e85db646ed391d4ffadd9c213
parent801daa75024fb177df1535f8e16a450bc68619fd
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/libelogind/sd-bus/bus-track.c
src/libelogind/sd-device/sd-device.c
src/libelogind/sd-hwdb/sd-hwdb.c
src/shared/fdset.c
src/shared/hashmap.c
src/shared/hashmap.h
src/shared/set.h