registry: refactor common part of registry initialization out.
authorMichael Adam <obnox@samba.org>
Sun, 13 Apr 2008 13:21:31 +0000 (15:21 +0200)
committerMichael Adam <obnox@samba.org>
Sun, 13 Apr 2008 13:33:48 +0000 (15:33 +0200)
into a new function registry_init_common().

Michael

source/registry/reg_init_basic.c
source/registry/reg_init_full.c
source/registry/reg_init_smbconf.c

index cdf172c2899b5e50ca5d7553790bf829fba8214d..c5e2c346b0c649dc6c19de8413c8fb0ef5e3882a 100644 (file)
 #undef DBGC_CLASS
 #define DBGC_CLASS DBGC_REGISTRY
 
-WERROR registry_init_basic(void)
+WERROR registry_init_common(void)
 {
        WERROR werr;
 
-       DEBUG(10, ("registry_init_basic called\n"));
-
        werr = regdb_init();
        if (!W_ERROR_IS_OK(werr)) {
-               DEBUG(1, ("Failed to initialize the registry: %s\n",
+               DEBUG(0, ("Failed to initialize the registry: %s\n",
                          dos_errstr(werr)));
                goto done;
        }
 
        werr = reghook_cache_init();
        if (!W_ERROR_IS_OK(werr)) {
-               DEBUG(1, ("Failed to initialize the reghook cache: %s\n",
+               DEBUG(0, ("Failed to initialize the reghook cache: %s\n",
                          dos_errstr(werr)));
        }
 
 done:
+       return werr;
+}
+
+WERROR registry_init_basic(void)
+{
+       WERROR werr;
+
+       DEBUG(10, ("registry_init_basic called\n"));
+
+       werr = registry_init_common();
        regdb_close();
        return werr;
 }
index e24cb61481b3aa4b069d5fbc97248d1e0e1fa1ce..ae12e307666de1467c17c0ff97bb25c8b6ae2426 100644 (file)
@@ -68,10 +68,8 @@ bool init_registry( void )
        WERROR werr;
        bool ret = false;
 
-       werr = regdb_init();
+       werr = registry_init_common();
        if (!W_ERROR_IS_OK(werr)) {
-               DEBUG(0, ("Failed to initialize the registry: %s\n",
-                         dos_errstr(werr)));
                goto fail;
        }
 
@@ -85,13 +83,6 @@ bool init_registry( void )
 
        /* build the cache tree of registry hooks */
 
-       werr = reghook_cache_init();
-       if (!W_ERROR_IS_OK(werr)) {
-               DEBUG(0, ("Failed to initialize the reghook cache: %s\n",
-                         dos_errstr(werr)));
-               goto fail;
-       }
-
        for ( i=0; reg_hooks[i].keyname; i++ ) {
                werr = reghook_cache_add(reg_hooks[i].keyname, reg_hooks[i].ops);
                if (!W_ERROR_IS_OK(werr)) {
index fafaf7952f6f691e36a59a5b4e900b6b784b5bfc..a05da854cfb84c80807514a1e9aa7341829ef862 100644 (file)
@@ -80,10 +80,8 @@ bool registry_init_smbconf(const char *keyname)
                keyname = KEY_SMBCONF;
        }
 
-       werr = regdb_init();
+       werr = registry_init_common();
        if (!W_ERROR_IS_OK(werr)) {
-               DEBUG(1, ("Failed to initialize the registry: %s\n",
-                         dos_errstr(werr)));
                goto done;
        }
 
@@ -94,13 +92,6 @@ bool registry_init_smbconf(const char *keyname)
                goto done;
        }
 
-       werr = reghook_cache_init();
-       if (!W_ERROR_IS_OK(werr)) {
-               DEBUG(1, ("Failed to initialize the reghook cache: %s\n",
-                         dos_errstr(werr)));
-               goto done;
-       }
-
        werr = reghook_cache_add(keyname, &smbconf_reg_ops);
        if (!W_ERROR_IS_OK(werr)) {
                DEBUG(1, ("Failed to add smbconf reghooks to reghook cache: "