[PATCH] loadparm: Simplify "set_variable"

Volker Lendecke Volker.Lendecke at SerNet.DE
Wed Jan 28 09:19:07 MST 2015


Hi!

Review&push appreciated!

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 78f1875e31ca27a5f8f6452a88c7b780bed78980 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Wed, 28 Jan 2015 16:16:32 +0000
Subject: [PATCH] loadparm: Simplify "set_variable"

I usually don't like complicated if/else and in particular the else
piece. But if the alternative is a goto, then else is better I guess :-)

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

diff --git a/lib/param/loadparm.c b/lib/param/loadparm.c
index bfa9c7b..115575c 100644
--- a/lib/param/loadparm.c
+++ b/lib/param/loadparm.c
@@ -1567,19 +1567,15 @@ bool set_variable(TALLOC_CTX *mem_ctx, struct loadparm_service *service, int par
 	if (parm_table[parmnum].special) {
 		ok = parm_table[parmnum].special(lp_ctx, service, pszParmValue,
 						  (char **)parm_ptr);
-		if (!ok) {
-			return false;
-		}
-		goto mark_non_default;
+	} else {
+		ok = set_variable_helper(mem_ctx, parmnum, parm_ptr,
+					 pszParmName, pszParmValue);
 	}
 
-	ok = set_variable_helper(mem_ctx, parmnum, parm_ptr, pszParmName, pszParmValue);
-
 	if (!ok) {
 		return false;
 	}
 
-mark_non_default:
 	if (on_globals && (lp_ctx->flags[parmnum] & FLAG_DEFAULT)) {
 		lp_ctx->flags[parmnum] &= ~FLAG_DEFAULT;
 		/* we have to also unset FLAG_DEFAULT on aliases */
-- 
1.7.9.5



More information about the samba-technical mailing list