From 8927b1dad2d4a7330174cb924090b4635a2547fb Mon Sep 17 00:00:00 2001 From: David Herrmann Date: Sun, 14 Jun 2015 16:51:35 +0200 Subject: 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/libsystemd/sd-bus/bus-track.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/libsystemd/sd-bus') diff --git a/src/libsystemd/sd-bus/bus-track.c b/src/libsystemd/sd-bus/bus-track.c index ec9340f8e1..e43891be25 100644 --- a/src/libsystemd/sd-bus/bus-track.c +++ b/src/libsystemd/sd-bus/bus-track.c @@ -248,7 +248,7 @@ _public_ const char* sd_bus_track_first(sd_bus_track *track) { track->modified = false; track->iterator = ITERATOR_FIRST; - hashmap_iterate(track->names, &track->iterator, (const void**) &n); + hashmap_iterate(track->names, &track->iterator, NULL, (const void**) &n); return n; } @@ -261,7 +261,7 @@ _public_ const char* sd_bus_track_next(sd_bus_track *track) { if (track->modified) return NULL; - hashmap_iterate(track->names, &track->iterator, (const void**) &n); + hashmap_iterate(track->names, &track->iterator, NULL, (const void**) &n); return n; } -- cgit v1.2.3-54-g00ecf