param: use a single add_to_file_list method
authorGarming Sam <garming@catalyst.net.nz>
Wed, 19 Feb 2014 22:01:52 +0000 (11:01 +1300)
committerJeremy Allison <jra@samba.org>
Wed, 7 May 2014 17:49:15 +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
lib/param/param.h
source3/param/loadparm.c

index ef46a54b153de05013268ed303d0d37f4af1b24f..d5b8d2c10bdb01df5b6a60ce547ee86cd5753e3e 100644 (file)
@@ -1006,10 +1006,10 @@ static bool lpcfg_service_ok(struct loadparm_service *service)
  it's date and needs to be reloaded.
 ********************************************************************/
 
-static void add_to_file_list(TALLOC_CTX *mem_ctx, struct file_lists **file,
+void add_to_file_list(TALLOC_CTX *mem_ctx, struct file_lists **list,
                             const char *fname, const char *subfname)
 {
-       struct file_lists *f = *file;
+       struct file_lists *f = *list;
 
        while (f) {
                if (f->name && !strcmp(f->name, fname))
@@ -1020,25 +1020,30 @@ static void add_to_file_list(TALLOC_CTX *mem_ctx, struct file_lists **file,
        if (!f) {
                f = talloc(mem_ctx, struct file_lists);
                if (!f)
-                       return;
-               f->next = *file;
+                       goto fail;
+               f->next = *list;
                f->name = talloc_strdup(f, fname);
                if (!f->name) {
-                       talloc_free(f);
-                       return;
+                       TALLOC_FREE(f);
+                       goto fail;
                }
                f->subfname = talloc_strdup(f, subfname);
                if (!f->subfname) {
-                       talloc_free(f);
-                       return;
+                       TALLOC_FREE(f);
+                       goto fail;
                }
-               *file = f;
+               *list = f;
                f->modtime = file_modtime(subfname);
        } else {
                time_t t = file_modtime(subfname);
                if (t)
                        f->modtime = t;
        }
+       return;
+
+fail:
+       DEBUG(0, ("Unable to add file to file list: %s\n", fname));
+
 }
 
 /*******************************************************************
index 0b65a3c827366ac6ba20df516baaabc3bafabe97..2fb6d4beddb8468bb773213c2f2bb4bf1fe68472 100644 (file)
@@ -47,6 +47,7 @@ struct smbcli_options;
 struct smbcli_session_options;
 struct gensec_settings;
 struct bitmap;
+struct file_lists;
 
 #ifdef CONFIG_H_IS_FROM_SAMBA
 #include "lib/param/param_proto.h"
index 544d7c0062e435c4a4c1e1abdeb4ed579e5e9486..9f67a9ebf388b292e8332c627e6e48ff04b7888a 100644 (file)
@@ -279,7 +279,6 @@ static bool handle_ldap_debug_level(struct loadparm_context *unused, int snum, c
 
 static void set_allowed_client_auth(void);
 
-static void add_to_file_list(TALLOC_CTX *mem_ctx, struct file_lists **f, const char *fname, const char *subfname);
 static bool lp_set_cmdline_helper(const char *pszParmName, const char *pszParmValue, bool store_values);
 static void free_param_opts(struct parmlist_entry **popts);
 
@@ -2358,51 +2357,6 @@ done:
 
 static uint8_t include_depth;
 
-/*******************************************************************
- Keep a linked list of all config files so we know when one has changed 
- it's date and needs to be reloaded.
-********************************************************************/
-
-static void add_to_file_list(TALLOC_CTX *mem_ctx, struct file_lists **list,
-                            const char *fname, const char *subfname)
-{
-       struct file_lists *f = *list;
-
-       while (f) {
-               if (f->name && !strcmp(f->name, fname))
-                       break;
-               f = f->next;
-       }
-
-       if (!f) {
-               f = talloc(mem_ctx, struct file_lists);
-               if (!f)
-                       goto fail;
-               f->next = *list;
-               f->name = talloc_strdup(f, fname);
-               if (!f->name) {
-                       TALLOC_FREE(f);
-                       goto fail;
-               }
-               f->subfname = talloc_strdup(f, subfname);
-               if (!f->subfname) {
-                       TALLOC_FREE(f);
-                       goto fail;
-               }
-               *list = f;
-               f->modtime = file_modtime(subfname);
-       } else {
-               time_t t = file_modtime(subfname);
-               if (t)
-                       f->modtime = t;
-       }
-       return;
-
-fail:
-       DEBUG(0, ("Unable to add file to file list: %s\n", fname));
-
-}
-
 /**
  * Free the file lists
  */