- *pkey = tdb_firstkey(the_tdb);
-
- dbuf = tdb_fetch(the_tdb, *pkey);
- if (!dbuf.dptr) terror("fetch failed");
+ enum TDB_ERROR ecode;
+ ecode = tdb_firstkey(the_tdb, pkey);
+ if (!ecode)
+ ecode = tdb_fetch(the_tdb, *pkey, &dbuf);
+ if (ecode) terror(ecode, "fetch failed");