dbwrap patches

Volker Lendecke Volker.Lendecke at SerNet.DE
Thu Nov 29 07:19:19 MST 2012


Hi!

While testing the parse_records patches further, I found
that in dbwrap_cache the parse_records pointer was not
initialized. As this has happened to me in the past, I went
through the backends and made sure all are using talloc_zero
for the db context that is returned. Attached find the set
of rather trivial patches that are either prerequisite or
sequel of the parse_records patches. If someone feels like
it, please push independently.

Thanks,

Volker

-- 
SerNet GmbH, Bahnhofsallee 1b, 37081 Göttingen
phone: +49-551-370000-0, fax: +49-551-370000-9
AG Göttingen, HRB 2816, GF: Dr. Johannes Loxen
http://www.sernet.de, mailto:kontakt at sernet.de
-------------- next part --------------
From 440349f3479d28c5e915a1ab42369f292159ddb2 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Thu, 29 Nov 2012 15:02:15 +0100
Subject: [PATCH 1/4] dbwrap: Use talloc_zero in db_open_cache

---
 lib/dbwrap/dbwrap_cache.c |    7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/lib/dbwrap/dbwrap_cache.c b/lib/dbwrap/dbwrap_cache.c
index f2a9c5f..d97242e 100644
--- a/lib/dbwrap/dbwrap_cache.c
+++ b/lib/dbwrap/dbwrap_cache.c
@@ -180,7 +180,7 @@ struct db_context *db_open_cache(TALLOC_CTX *mem_ctx,
 	struct db_context *db;
 	struct db_cache_ctx *ctx;
 
-	db = talloc(mem_ctx, struct db_context);
+	db = talloc_zero(mem_ctx, struct db_context);
 	if (db == NULL) {
 		return NULL;
 	}
@@ -199,7 +199,6 @@ struct db_context *db_open_cache(TALLOC_CTX *mem_ctx,
 	}
 
 	db->fetch_locked = dbwrap_cache_fetch_locked;
-	db->try_fetch_locked = NULL;
 	db->traverse = dbwrap_cache_traverse;
 	db->traverse_read = dbwrap_cache_traverse_read;
 	db->get_seqnum = dbwrap_cache_get_seqnum;
@@ -211,9 +210,5 @@ struct db_context *db_open_cache(TALLOC_CTX *mem_ctx,
 	db->id = dbwrap_cache_id;
 	db->name = dbwrap_name(ctx->backing);
 	db->hash_size = dbwrap_hash_size(ctx->backing);
-	db->stored_callback = NULL;
-	db->wipe = NULL;
-	db->lock_order = 0;
-	db->persistent = false;
 	return db;
 }
-- 
1.7.9.5


From 052add3ef740bce141b8dc5be7d0921b6be9e331 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Thu, 29 Nov 2012 15:02:43 +0100
Subject: [PATCH 2/4] dbwrap: Use talloc_zero in db_open_rbt

---
 lib/dbwrap/dbwrap_rbt.c |    6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/lib/dbwrap/dbwrap_rbt.c b/lib/dbwrap/dbwrap_rbt.c
index afe9974..3f97086 100644
--- a/lib/dbwrap/dbwrap_rbt.c
+++ b/lib/dbwrap/dbwrap_rbt.c
@@ -480,7 +480,7 @@ struct db_context *db_open_rbt(TALLOC_CTX *mem_ctx)
 {
 	struct db_context *result;
 
-	result = talloc(mem_ctx, struct db_context);
+	result = talloc_zero(mem_ctx, struct db_context);
 
 	if (result == NULL) {
 		return NULL;
@@ -494,7 +494,6 @@ struct db_context *db_open_rbt(TALLOC_CTX *mem_ctx)
 	}
 
 	result->fetch_locked = db_rbt_fetch_locked;
-	result->try_fetch_locked = NULL;
 	result->traverse = db_rbt_traverse;
 	result->traverse_read = db_rbt_traverse_read;
 	result->get_seqnum = db_rbt_get_seqnum;
@@ -504,11 +503,8 @@ struct db_context *db_open_rbt(TALLOC_CTX *mem_ctx)
 	result->exists = db_rbt_exists;
 	result->wipe = db_rbt_wipe;
 	result->parse_record = db_rbt_parse_record;
-	result->lock_order = 0;
 	result->id = db_rbt_id;
 	result->name = "dbwrap rbt";
-	result->hash_size = 0;
-	result->stored_callback = NULL;
 
 	return result;
 }
-- 
1.7.9.5


From 9695eb9e3fb7defb8ad54f52064e8b24511a010b Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Thu, 29 Nov 2012 15:03:20 +0100
Subject: [PATCH 3/4] dbwrap: No need to NULL out a talloc_zero'ed structure
 element

---
 lib/dbwrap/dbwrap_tdb.c |    1 -
 1 file changed, 1 deletion(-)

diff --git a/lib/dbwrap/dbwrap_tdb.c b/lib/dbwrap/dbwrap_tdb.c
index a3a6c87..f9c7ba4 100644
--- a/lib/dbwrap/dbwrap_tdb.c
+++ b/lib/dbwrap/dbwrap_tdb.c
@@ -473,7 +473,6 @@ struct db_context *db_open_tdb(TALLOC_CTX *mem_ctx,
 	result->wipe = db_tdb_wipe;
 	result->id = db_tdb_id;
 	result->check = db_tdb_check;
-	result->stored_callback = NULL;
 	result->name = tdb_name(db_tdb->wtdb->tdb);
 	result->hash_size = hash_size;
 	return result;
-- 
1.7.9.5


From 77c8b841a8ec688c0efa982625e27e5c0574dbd6 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Thu, 29 Nov 2012 15:04:33 +0100
Subject: [PATCH 4/4] dbwrap: Remove an unnecessary if-statement

TALLOC_FREE can live with a NULL pointer
---
 lib/dbwrap/dbwrap_tdb.c |    4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/lib/dbwrap/dbwrap_tdb.c b/lib/dbwrap/dbwrap_tdb.c
index f9c7ba4..b62dcdf 100644
--- a/lib/dbwrap/dbwrap_tdb.c
+++ b/lib/dbwrap/dbwrap_tdb.c
@@ -478,8 +478,6 @@ struct db_context *db_open_tdb(TALLOC_CTX *mem_ctx,
 	return result;
 
  fail:
-	if (result != NULL) {
-		TALLOC_FREE(result);
-	}
+	TALLOC_FREE(result);
 	return NULL;
 }
-- 
1.7.9.5



More information about the samba-technical mailing list