From 141148edd34c587f4e0f5b992d71201ade541d70 Mon Sep 17 00:00:00 2001 From: Gary Lockyer Date: Tue, 13 Feb 2018 15:21:34 +1300 Subject: [PATCH] ldb_tdb: Add errorstr to the key value ops Signed-off-by: Garming Sam Reviewed-by: Andrew Bartlett --- lib/ldb/ldb_tdb/ldb_tdb.c | 12 +++++++++--- lib/ldb/ldb_tdb/ldb_tdb.h | 1 + 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/ldb/ldb_tdb/ldb_tdb.c b/lib/ldb/ldb_tdb/ldb_tdb.c index d7fe4917965..6cdd5733b98 100644 --- a/lib/ldb/ldb_tdb/ldb_tdb.c +++ b/lib/ldb/ldb_tdb/ldb_tdb.c @@ -423,6 +423,11 @@ static int ltdb_error(struct ltdb_private *ltdb) return ltdb_err_map(tdb_error(ltdb->tdb)); } +static const char *ltdb_errorstr(struct ltdb_private *ltdb) +{ + return tdb_errorstr(ltdb->tdb); +} + /* store a record into the db */ @@ -1465,8 +1470,8 @@ static int ltdb_prepare_commit(struct ldb_module *module) ldb_debug_set(ldb_module_get_ctx(module), LDB_DEBUG_FATAL, "Failure during " - "tdb_transaction_prepare_commit(): %s -> %s", - tdb_errorstr(ltdb->tdb), + "prepare_write): %s -> %s", + ltdb->kv_ops->errorstr(ltdb), ldb_strerror(ret)); return ret; } @@ -1496,7 +1501,7 @@ static int ltdb_end_trans(struct ldb_module *module) ret = ltdb->kv_ops->error(ltdb); ldb_asprintf_errstring(ldb_module_get_ctx(module), "Failure during tdb_transaction_commit(): %s -> %s", - tdb_errorstr(ltdb->tdb), + ltdb->kv_ops->errorstr(ltdb), ldb_strerror(ret)); return ret; } @@ -1733,6 +1738,7 @@ static const struct kv_db_ops key_value_ops = { .finish_write = ltdb_tdb_transaction_commit, .abort_write = ltdb_tdb_transaction_cancel, .error = ltdb_error, + .errorstr = ltdb_errorstr, .name = ltdb_tdb_name, .has_changed = ltdb_tdb_changed, }; diff --git a/lib/ldb/ldb_tdb/ldb_tdb.h b/lib/ldb/ldb_tdb/ldb_tdb.h index ba827f92a88..5c930bf997a 100644 --- a/lib/ldb/ldb_tdb/ldb_tdb.h +++ b/lib/ldb/ldb_tdb/ldb_tdb.h @@ -15,6 +15,7 @@ struct kv_db_ops { int (*abort_write)(struct ltdb_private *); int (*finish_write)(struct ltdb_private *); int (*error)(struct ltdb_private *ltdb); + const char * (*errorstr)(struct ltdb_private *ltdb); const char * (*name)(struct ltdb_private *ltdb); bool (*has_changed)(struct ltdb_private *ltdb); };