summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ccan/tdb2/doc/TDB1_porting.txt6
-rw-r--r--ccan/tdb2/tdb.c5
2 files changed, 9 insertions, 2 deletions
diff --git a/ccan/tdb2/doc/TDB1_porting.txt b/ccan/tdb2/doc/TDB1_porting.txt
index 7a169f3a..90ba2497 100644
--- a/ccan/tdb2/doc/TDB1_porting.txt
+++ b/ccan/tdb2/doc/TDB1_porting.txt
@@ -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).
diff --git a/ccan/tdb2/tdb.c b/ccan/tdb2/tdb.c
index 09333a26..1dbbb7e9 100644
--- a/ccan/tdb2/tdb.c
+++ b/ccan/tdb2/tdb.c
@@ -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,