[PATCH] Two cleanups

Volker Lendecke Volker.Lendecke at SerNet.DE
Wed Nov 26 14:13:40 MST 2014


Hi!

I'd appreciate review&push.

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 f82be0c81108e99cb3f13e8fbe8b8567b9ca08e1 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Wed, 26 Nov 2014 21:34:44 +0100
Subject: [PATCH 1/2] registry3: Fix a typo

Signed-off-by: Volker Lendecke <vl at samba.org>
---
 source3/registry/reg_init_full.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/source3/registry/reg_init_full.c b/source3/registry/reg_init_full.c
index b222d13..e47b3f6 100644
--- a/source3/registry/reg_init_full.c
+++ b/source3/registry/reg_init_full.c
@@ -69,7 +69,7 @@ struct registry_hook reg_hooks[] = {
 
 /***********************************************************************
  Open the registry database and initialize the registry_hook cache
- with all available backens.
+ with all available backends.
  ***********************************************************************/
 
 WERROR registry_init_full(void)
-- 
1.9.1


From bf715d54c276b0ce74b8f99730bafc10a382dbe7 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Wed, 26 Nov 2014 21:35:27 +0100
Subject: [PATCH 2/2] param: Simplify get_parametric_helper()

With variable sized arrays we don't need talloc_asprintf here

Signed-off-by: Volker Lendecke <vl at samba.org>
---
 lib/param/loadparm.c | 19 ++++---------------
 1 file changed, 4 insertions(+), 15 deletions(-)

diff --git a/lib/param/loadparm.c b/lib/param/loadparm.c
index 9953053..40fc454 100644
--- a/lib/param/loadparm.c
+++ b/lib/param/loadparm.c
@@ -241,16 +241,12 @@ struct parmlist_entry *get_parametric_helper(struct loadparm_service *service,
 					     const char *type, const char *option,
 					     struct parmlist_entry *global_opts)
 {
-	char* param_key;
+	size_t type_len = strlen(type);
+	size_t option_len = strlen(option);
+	char param_key[type_len + option_len + 2];
 	struct parmlist_entry *data = NULL;
-	TALLOC_CTX *mem_ctx = talloc_stackframe();
 
-	param_key = talloc_asprintf(mem_ctx, "%s:%s", type, option);
-	if (param_key == NULL) {
-		DEBUG(0,("asprintf failed!\n"));
-		TALLOC_FREE(mem_ctx);
-		return NULL;
-	}
+	snprintf(param_key, sizeof(param_key), "%s:%s", type, option);
 
 	/*
 	 * Try to fetch the option from the data.
@@ -259,7 +255,6 @@ struct parmlist_entry *get_parametric_helper(struct loadparm_service *service,
 		data = service->param_opt;
 		while (data != NULL) {
 			if (strwicmp(data->key, param_key) == 0) {
-				TALLOC_FREE(mem_ctx);
 				return data;
 			}
 			data = data->next;
@@ -272,18 +267,12 @@ struct parmlist_entry *get_parametric_helper(struct loadparm_service *service,
 	data = global_opts;
 	while (data != NULL) {
 		if (strwicmp(data->key, param_key) == 0) {
-			TALLOC_FREE(mem_ctx);
 			return data;
 		}
 		data = data->next;
 	}
 
-
-	TALLOC_FREE(mem_ctx);
-
 	return NULL;
-
-
 }
 
 const char *lpcfg_get_parametric(struct loadparm_context *lp_ctx,
-- 
1.9.1



More information about the samba-technical mailing list