summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: bab2df9)
raw | patch | inline | side by side (parent: bab2df9)
author | Sebastian Harl <sh@tokkee.org> | |
Sat, 17 Jan 2015 00:26:07 +0000 (01:26 +0100) | ||
committer | Sebastian Harl <sh@tokkee.org> | |
Sat, 17 Jan 2015 19:31:40 +0000 (11:31 -0800) |
src/core/store.c | patch | blob | history | |
t/unit/core/store_test.c | patch | blob | history |
diff --git a/src/core/store.c b/src/core/store.c
index e6aeaf63e86f3c8a6d56e7682f065801396e481d..345b5ea86bf2555c42961b4778ccb800743066b7 100644 (file)
--- a/src/core/store.c
+++ b/src/core/store.c
sdb_store_scan(int type, sdb_store_matcher_t *m, sdb_store_matcher_t *filter,
sdb_store_lookup_cb cb, void *user_data)
{
- sdb_avltree_iter_t *host_iter;
+ sdb_avltree_iter_t *host_iter = NULL;
int status = 0;
if (! cb)
pthread_rwlock_rdlock(&host_lock);
- host_iter = sdb_avltree_get_iter(hosts);
- if (! host_iter)
- status = -1;
+ if (hosts) {
+ host_iter = sdb_avltree_get_iter(hosts);
+ if (! host_iter)
+ status = -1;
+ }
/* has_next returns false if the iterator is NULL */
while (sdb_avltree_iter_has_next(host_iter)) {
index 262f681de1ba8a7b69ca846ba20525b60cf67820..aab93aab1671a6995818b3da64fede48ec4d37b5 100644 (file)
--- a/t/unit/core/store_test.c
+++ b/t/unit/core/store_test.c
/* empty store */
check = sdb_store_scan(SDB_HOST, /* m, filter = */ NULL, NULL,
scan_count, &i);
- fail_unless(check == -1,
- "sdb_store_scan(HOST), empty store = %d; expected: -1", check);
+ fail_unless(check == 0,
+ "sdb_store_scan(HOST), empty store = %d; expected: 0", check);
fail_unless(i == 0,
"sdb_store_scan(HOST) called callback %d times; "
"expected: 0", (int)i);