Skip to content

Commit fa894a0

Browse files
committed
fixup! lib: better error reporting for xbps_array_foreach_cb_multi
1 parent 08456e1 commit fa894a0

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

lib/pkgdb.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -380,16 +380,17 @@ xbps_pkgdb_foreach_cb(struct xbps_handle *xhp,
380380
void *arg)
381381
{
382382
xbps_array_t allkeys;
383-
int rv;
383+
int r;
384384

385-
if ((rv = xbps_pkgdb_init(xhp)) != 0)
386-
return rv;
385+
// XXX: this should be done before calling the function...
386+
if ((r = xbps_pkgdb_init(xhp)) != 0)
387+
return r > 0 ? -r : r;
387388

388389
allkeys = xbps_dictionary_all_keys(xhp->pkgdb);
389390
assert(allkeys);
390-
rv = xbps_array_foreach_cb(xhp, allkeys, xhp->pkgdb, fn, arg);
391+
r = xbps_array_foreach_cb(xhp, allkeys, xhp->pkgdb, fn, arg);
391392
xbps_object_release(allkeys);
392-
return rv;
393+
return r;
393394
}
394395

395396
int
@@ -400,7 +401,9 @@ xbps_pkgdb_foreach_cb_multi(struct xbps_handle *xhp,
400401
xbps_array_t allkeys;
401402
int r;
402403

403-
assert(xhp->pkgdb);
404+
// XXX: this should be done before calling the function...
405+
if ((r = xbps_pkgdb_init(xhp)) != 0)
406+
return r > 0 ? -r : r;
404407

405408
allkeys = xbps_dictionary_all_keys(xhp->pkgdb);
406409
if (!allkeys)

0 commit comments

Comments
 (0)