]> git.ozlabs.org Git - ccan/commitdiff
tdb2: actually implement tdb_error().
authorRusty Russell <rusty@rustcorp.com.au>
Thu, 24 Mar 2011 01:26:38 +0000 (11:56 +1030)
committerRusty Russell <rusty@rustcorp.com.au>
Thu, 24 Mar 2011 01:26:38 +0000 (11:56 +1030)
I'm still not sure it'll last into the final version, but finish the
implementation.

ccan/tdb2/doc/TDB1_porting.txt
ccan/tdb2/tdb.c

index 7a169f3a6bee5aed3e8a839af450f72cee47aff9..90ba2497382d456e285ec6990c5eb86177dbe812 100644 (file)
@@ -4,8 +4,10 @@ Interface differences between TDB1 and TDB2.
   TDB_DATA typedef if you want portability between the two.
 
 - tdb2 functions return 0 on success, and a negative error on failure,
-  whereas tdb1 functions returned 0 on success, and -1 on failure.  tdb1
-  then used tdb_error() to determine the error.
+  whereas tdb1 functions returned 0 on success, and -1 on failure.
+  tdb1 then used tdb_error() to determine the error; this is also
+  supported in tdb2 to ease backwards compatibility, though the other
+  form is preferred.
 
 - tdb2's tdb_fetch() returns an error, tdb1's returned the data directly
   (or tdb_null, and you were supposed to check tdb_error() to find out why).
index 09333a26801380fb232a2fc444eb11473de8805e..1dbbb7e93bdf46c16e8200abb9b5e0b3b3a885f4 100644 (file)
@@ -382,6 +382,11 @@ const char *tdb_errorstr(enum TDB_ERROR ecode)
        return "Invalid error code";
 }
 
+enum TDB_ERROR tdb_error(struct tdb_context *tdb)
+{
+       return tdb->last_error;
+}
+
 enum TDB_ERROR COLD tdb_logerr(struct tdb_context *tdb,
                               enum TDB_ERROR ecode,
                               enum tdb_log_level level,