From: Volker Lendecke Date: Wed, 26 Jul 2017 12:56:53 +0000 (+0200) Subject: dbwrap: Simplify dbwrap_store_uint32_bystring X-Git-Tag: tdb-1.3.15~83 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=b01b7c9ef9ef45205c6eb49a5959d8718559fd79;p=thirdparty%2Fsamba.git dbwrap: Simplify dbwrap_store_uint32_bystring Signed-off-by: Volker Lendecke Reviewed-by: Jeremy Allison --- diff --git a/lib/dbwrap/dbwrap_util.c b/lib/dbwrap/dbwrap_util.c index 443a915df2d..c7971a95b85 100644 --- a/lib/dbwrap/dbwrap_util.c +++ b/lib/dbwrap/dbwrap_util.c @@ -133,23 +133,14 @@ NTSTATUS dbwrap_fetch_uint32_bystring(struct db_context *db, NTSTATUS dbwrap_store_uint32_bystring(struct db_context *db, const char *keystr, uint32_t v) { - struct db_record *rec; - uint32_t v_store; + uint8_t v_store[sizeof(uint32_t)]; + TDB_DATA data = { .dptr = v_store, .dsize = sizeof(v_store) }; NTSTATUS status; - rec = dbwrap_fetch_locked(db, talloc_tos(), - string_term_tdb_data(keystr)); - if (rec == NULL) { - return NT_STATUS_INVALID_PARAMETER; - } - - SIVAL(&v_store, 0, v); + SIVAL(v_store, 0, v); - status = dbwrap_record_store(rec, - make_tdb_data((const uint8_t *)&v_store, - sizeof(v_store)), - TDB_REPLACE); - TALLOC_FREE(rec); + status = dbwrap_store(db, string_term_tdb_data(keystr), data, + TDB_REPLACE); return status; }