summaryrefslogtreecommitdiff
path: root/lib/param
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2015-08-17 21:07:37 +0200
committerVolker Lendecke <vl@samba.org>2015-08-21 11:43:05 +0200
commit0f600c34599a61a4c338b1e10af438016bec0b14 (patch)
tree4bb6e5e5e6cf92c2b987a653819dee8df3ba67d0 /lib/param
parent78d7512db9e0098c5ae16111b1338eaa80673d5e (diff)
downloadsamba-0f600c34599a61a4c338b1e10af438016bec0b14.tar.gz
param: Simplify set_param_opt()
"not_added" is not a very good boolean flag concept... An early return serves the same purpose just as well. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
Diffstat (limited to 'lib/param')
-rw-r--r--lib/param/loadparm.c36
1 files changed, 16 insertions, 20 deletions
diff --git a/lib/param/loadparm.c b/lib/param/loadparm.c
index 0a1c29a129f..c62e0dee911 100644
--- a/lib/param/loadparm.c
+++ b/lib/param/loadparm.c
@@ -802,10 +802,8 @@ void set_param_opt(TALLOC_CTX *mem_ctx,
unsigned priority)
{
struct parmlist_entry *new_opt, *opt;
- bool not_added;
opt = *opt_list;
- not_added = true;
/* Traverse destination */
while (opt) {
@@ -821,31 +819,29 @@ void set_param_opt(TALLOC_CTX *mem_ctx,
TALLOC_FREE(opt->list);
opt->value = talloc_strdup(opt, opt_value);
opt->priority = priority;
- not_added = false;
- break;
+ return;
}
opt = opt->next;
}
- if (not_added) {
- new_opt = talloc(mem_ctx, struct parmlist_entry);
- if (new_opt == NULL) {
- smb_panic("OOM");
- }
- new_opt->key = talloc_strdup(new_opt, opt_name);
- if (new_opt->key == NULL) {
- smb_panic("talloc_strdup failed");
- }
+ new_opt = talloc(mem_ctx, struct parmlist_entry);
+ if (new_opt == NULL) {
+ smb_panic("OOM");
+ }
- new_opt->value = talloc_strdup(new_opt, opt_value);
- if (new_opt->value == NULL) {
- smb_panic("talloc_strdup failed");
- }
+ new_opt->key = talloc_strdup(new_opt, opt_name);
+ if (new_opt->key == NULL) {
+ smb_panic("talloc_strdup failed");
+ }
- new_opt->list = NULL;
- new_opt->priority = priority;
- DLIST_ADD(*opt_list, new_opt);
+ new_opt->value = talloc_strdup(new_opt, opt_value);
+ if (new_opt->value == NULL) {
+ smb_panic("talloc_strdup failed");
}
+
+ new_opt->list = NULL;
+ new_opt->priority = priority;
+ DLIST_ADD(*opt_list, new_opt);
}
/**