mirror of
https://github.com/samba-team/samba.git
synced 2024-12-23 17:34:34 +03:00
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>
This commit is contained in:
parent
78d7512db9
commit
0f600c3459
@ -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->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);
|
||||
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->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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user