s3:registry: introduce a define REGDB_CODE_VERSION and use it in regdb code.
authorMichael Adam <obnox@samba.org>
Thu, 1 Sep 2011 22:34:12 +0000 (00:34 +0200)
committerMichael Adam <obnox@samba.org>
Tue, 11 Oct 2011 13:21:18 +0000 (15:21 +0200)
This is to not use the precise code version REGDB_VERSION_V3 explicitly
in the code.

source3/registry/reg_backend_db.c
source3/registry/reg_db.h

index a0c9c71bdee9b22339971283a17970310584497c..8a468ab3d5b621d149b0b44e9efe7fe1e242bc12 100644 (file)
@@ -71,11 +71,11 @@ static NTSTATUS regdb_trans_do_action(struct db_context *db, void *private_data)
 
        version_id = dbwrap_fetch_int32(db, REGDB_VERSION_KEYNAME);
 
-       if (version_id != REGDB_VERSION_V3) {
+       if (version_id != REGDB_CODE_VERSION) {
                DEBUG(0, ("ERROR: changed registry version %d found while "
                          "trying to write to the registry. Version %d "
                          "expected.  Denying access.\n",
-                         version_id, REGDB_VERSION_V3));
+                         version_id, REGDB_CODE_VERSION));
                return NT_STATUS_ACCESS_DENIED;
        }
 
@@ -616,7 +616,7 @@ done:
 
 WERROR regdb_init(void)
 {
-       uint32 vers_id, expected_version;
+       uint32 vers_id;
        WERROR werr;
 
        if (regdb) {
@@ -645,22 +645,20 @@ WERROR regdb_init(void)
        DEBUG(10, ("regdb_init: registry db openend. refcount reset (%d)\n",
                   regdb_refcount));
 
-       expected_version = REGDB_VERSION_V3;
-
        vers_id = dbwrap_fetch_int32(regdb, REGDB_VERSION_KEYNAME);
        if (vers_id == -1) {
                DEBUG(10, ("regdb_init: registry version uninitialized "
                           "(got %d), initializing to version %d\n",
-                          vers_id, expected_version));
+                          vers_id, REGDB_CODE_VERSION));
 
-               werr = regdb_store_regdb_version(regdb, expected_version);
+               werr = regdb_store_regdb_version(regdb, REGDB_CODE_VERSION);
                return werr;
        }
 
-       if (vers_id > expected_version || vers_id == 0) {
+       if (vers_id > REGDB_CODE_VERSION || vers_id == 0) {
                DEBUG(0, ("regdb_init: unknown registry version %d "
                          "(code version = %d), refusing initialization\n",
-                         vers_id, expected_version));
+                         vers_id, REGDB_CODE_VERSION));
                return WERR_CAN_NOT_COMPLETE;
        }
 
index 9782c1eab4cef3346c7e1d4ec9920be2487d6f5f..d0d9fd393178a24f9e5ddbf82a5bc6b129b03f06 100644 (file)
@@ -27,6 +27,8 @@
 #define REGDB_VERSION_V3    3  /* different definition of key existence, */
                                /* sorted subkeys cache removed. */
 
+#define REGDB_CODE_VERSION REGDB_VERSION_V3
+
 #define REG_VALUE_PREFIX    "SAMBA_REGVAL"
 #define REG_SECDESC_PREFIX  "SAMBA_SECDESC"
 #define REG_SORTED_SUBKEYS_PREFIX  "SAMBA_SORTED_SUBKEYS"