lib/param: use get_parametric_helper in lpcfg_get_parametric
authorGarming Sam <garming@catalyst.net.nz>
Tue, 25 Feb 2014 04:02:52 +0000 (17:02 +1300)
committerJeremy Allison <jra@samba.org>
Wed, 7 May 2014 17:49:17 +0000 (19:49 +0200)
Signed-off-by: Garming Sam <garming@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
lib/param/loadparm.c

index 7728e6dd0c7a0e4f64391c90ff93362edfb5be1b..fd0c827d1a257437f7bd210805263bff773b176c 100644 (file)
@@ -290,7 +290,6 @@ const char *lpcfg_get_parametric(struct loadparm_context *lp_ctx,
                              struct loadparm_service *service,
                              const char *type, const char *option)
 {
-       char *vfskey = NULL;
        struct parmlist_entry *data;
 
        if (lp_ctx == NULL)
@@ -300,40 +299,14 @@ const char *lpcfg_get_parametric(struct loadparm_context *lp_ctx,
                return lp_ctx->s3_fns->get_parametric(service, type, option, NULL);
        }
 
-       vfskey = talloc_asprintf(NULL, "%s:%s", type, option);
-       if (vfskey == NULL) {
-               DEBUG(0,("asprintf failed!\n"));
-               return NULL;
-       }
-
-       /*
-        * Try to fetch the option from the service.
-        */
-       if (service != NULL) {
-               for (data = service->param_opt; data;
-                    data = data->next) {
-                       if (strwicmp(data->key, vfskey) == 0) {
-                               talloc_free(vfskey);
-                               return data->value;
-                       }
-               }
-       }
+       data = get_parametric_helper(service,
+                                    type, option, lp_ctx->globals->param_opt);
 
-       /*
-        * Fall back to fetching from the globals.
-        */
-       data = lp_ctx->globals->param_opt;
-       while (data) {
-               if (strwicmp(data->key, vfskey) == 0) {
-                       talloc_free(vfskey);
-                       return data->value;
-               }
-               data = data->next;
+       if (data == NULL) {
+               return NULL;
+       } else {
+               return data->value;
        }
-
-       talloc_free(vfskey);
-
-       return NULL;
 }