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/basic/fdset.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/basic/fdset.c') diff --git a/src/basic/fdset.c b/src/basic/fdset.c index 6101b628ec..a4823e6659 100644 --- a/src/basic/fdset.c +++ b/src/basic/fdset.c @@ -267,8 +267,7 @@ bool fdset_isempty(FDSet *fds) { int fdset_iterate(FDSet *s, Iterator *i) { void *p; - p = set_iterate(MAKE_SET(s), i); - if (!p) + if (!set_iterate(MAKE_SET(s), i, &p)) return -ENOENT; return PTR_TO_FD(p); -- cgit v1.2.3-54-g00ecf