summaryrefslogtreecommitdiff
path: root/source3/param
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2008-07-16 16:05:46 +0200
committerVolker Lendecke <vl@samba.org>2008-07-16 18:21:17 +0200
commitd11796d392d3bcc7a1aba8ef0046ad497f00035a (patch)
tree6b9eee2f17a3e0cfb9c3d01cd69d4468a5306059 /source3/param
parented5e6b3244c9ea0752999b24c793ba1bdffe67e9 (diff)
downloadsamba-d11796d392d3bcc7a1aba8ef0046ad497f00035a.tar.gz
samba-d11796d392d3bcc7a1aba8ef0046ad497f00035a.tar.bz2
samba-d11796d392d3bcc7a1aba8ef0046ad497f00035a.zip
Tiny logic simplification: Remove an indentation by using an early return;
(This used to be commit 37dba0c192ec7d4105465beae0d6e8598c7dbb7a)
Diffstat (limited to 'source3/param')
-rw-r--r--source3/param/loadparm.c102
1 files changed, 56 insertions, 46 deletions
diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c
index 5cc373586c..b77a0488c2 100644
--- a/source3/param/loadparm.c
+++ b/source3/param/loadparm.c
@@ -7117,61 +7117,71 @@ bool lp_do_parameter(int snum, const char *pszParmName, const char *pszParmValue
void *parm_ptr = NULL; /* where we are going to store the result */
void *def_ptr = NULL;
char *param_key = NULL;
- char *sep;
struct param_opt_struct *paramo, *data;
bool not_added;
parmnum = map_parameter(pszParmName);
if (parmnum < 0) {
- if ((sep=strchr(pszParmName, ':')) != NULL) {
- TALLOC_CTX *frame = talloc_stackframe();
-
- *sep = '\0';
- param_key = talloc_asprintf(frame, "%s:", pszParmName);
- if (!param_key) {
- TALLOC_FREE(frame);
- return false;
- }
- slen = strlen(param_key);
- param_key = talloc_asprintf_append(param_key, sep+1);
- if (!param_key) {
- TALLOC_FREE(frame);
- return false;
- }
- trim_char(param_key+slen, ' ', ' ');
- not_added = True;
- data = (snum < 0) ? Globals.param_opt :
- ServicePtrs[snum]->param_opt;
- /* Traverse destination */
- while (data) {
- /* If we already have same option, override it */
- if (strcmp(data->key, param_key) == 0) {
- string_free(&data->value);
- TALLOC_FREE(data->list);
- data->value = SMB_STRDUP(pszParmValue);
- not_added = False;
- break;
- }
- data = data->next;
- }
- if (not_added) {
- paramo = SMB_XMALLOC_P(struct param_opt_struct);
- paramo->key = SMB_STRDUP(param_key);
- paramo->value = SMB_STRDUP(pszParmValue);
- paramo->list = NULL;
- if (snum < 0) {
- DLIST_ADD(Globals.param_opt, paramo);
- } else {
- DLIST_ADD(ServicePtrs[snum]->param_opt, paramo);
- }
- }
+ char *sep;
+ TALLOC_CTX *frame;
- *sep = ':';
- TALLOC_FREE(frame);
+ sep = strchr(pszParmName, ':');
+ if (sep == NULL) {
+ DEBUG(0, ("Ignoring unknown parameter \"%s\"\n",
+ pszParmName));
return (True);
}
- DEBUG(0, ("Ignoring unknown parameter \"%s\"\n", pszParmName));
+
+ /*
+ * We've got a parametric option
+ */
+
+ frame = talloc_stackframe();
+
+ *sep = '\0';
+ param_key = talloc_asprintf(frame, "%s:", pszParmName);
+ if (!param_key) {
+ TALLOC_FREE(frame);
+ return false;
+ }
+ slen = strlen(param_key);
+ param_key = talloc_asprintf_append(param_key, sep+1);
+ if (!param_key) {
+ TALLOC_FREE(frame);
+ return false;
+ }
+ trim_char(param_key+slen, ' ', ' ');
+ not_added = True;
+ data = (snum < 0)
+ ? Globals.param_opt : ServicePtrs[snum]->param_opt;
+ /* Traverse destination */
+ while (data) {
+ /* If we already have same option, override it */
+ if (strcmp(data->key, param_key) == 0) {
+ string_free(&data->value);
+ TALLOC_FREE(data->list);
+ data->value = SMB_STRDUP(pszParmValue);
+ not_added = False;
+ break;
+ }
+ data = data->next;
+ }
+ if (not_added) {
+ paramo = SMB_XMALLOC_P(struct param_opt_struct);
+ paramo->key = SMB_STRDUP(param_key);
+ paramo->value = SMB_STRDUP(pszParmValue);
+ paramo->list = NULL;
+ if (snum < 0) {
+ DLIST_ADD(Globals.param_opt, paramo);
+ } else {
+ DLIST_ADD(ServicePtrs[snum]->param_opt,
+ paramo);
+ }
+ }
+
+ *sep = ':';
+ TALLOC_FREE(frame);
return (True);
}