]> git.ozlabs.org Git - ccan/blobdiff - ccan/tdb2/summary.c
tdb2: rework some io.c functions to encode errors in their pointer returns.
[ccan] / ccan / tdb2 / summary.c
index d279131d3eec65561a9e86c3bb6e80412e7aef9b..61d7689749caa6a37b8883439d4ba7c4bcbc524a 100644 (file)
@@ -26,8 +26,10 @@ static int count_hash(struct tdb_context *tdb,
        unsigned int i, count = 0;
 
        h = tdb_access_read(tdb, hash_off, sizeof(*h) << bits, true);
        unsigned int i, count = 0;
 
        h = tdb_access_read(tdb, hash_off, sizeof(*h) << bits, true);
-       if (!h)
+       if (TDB_PTR_IS_ERR(h)) {
+               tdb->ecode = TDB_PTR_ERR(h);
                return -1;
                return -1;
+       }
        for (i = 0; i < (1 << bits); i++)
                count += (h[i] != 0);
 
        for (i = 0; i < (1 << bits); i++)
                count += (h[i] != 0);
 
@@ -58,8 +60,10 @@ static bool summarize(struct tdb_context *tdb,
                } *p;
                /* We might not be able to get the whole thing. */
                p = tdb_access_read(tdb, off, sizeof(p->f), true);
                } *p;
                /* We might not be able to get the whole thing. */
                p = tdb_access_read(tdb, off, sizeof(p->f), true);
-               if (!p)
+               if (TDB_PTR_IS_ERR(p)) {
+                       tdb->ecode = TDB_PTR_ERR(p);
                        return false;
                        return false;
+               }
                if (p->r.magic == TDB_RECOVERY_INVALID_MAGIC
                    || p->r.magic == TDB_RECOVERY_MAGIC) {
                        if (unc) {
                if (p->r.magic == TDB_RECOVERY_INVALID_MAGIC
                    || p->r.magic == TDB_RECOVERY_MAGIC) {
                        if (unc) {