s4:libregistry - change counters to be "unsigned"
authorMatthias Dieter Wallnöfer <mwallnoefer@yahoo.de>
Sat, 7 Nov 2009 20:07:20 +0000 (21:07 +0100)
committerMatthias Dieter Wallnöfer <mwallnoefer@yahoo.de>
Sat, 6 Mar 2010 16:48:25 +0000 (17:48 +0100)
Also the s4 registry library has to have "unsigned" counters like the Windows
one.

source4/lib/registry/dir.c
source4/lib/registry/interface.c
source4/lib/registry/ldb.c
source4/lib/registry/local.c
source4/lib/registry/patchfile.c
source4/lib/registry/regf.c
source4/lib/registry/registry.h
source4/lib/registry/tools/regshell.c
source4/lib/registry/tools/regtree.c
source4/lib/registry/util.c

index 42946bceeca00a7aed6e0ef571c59589cdd6fe39..4380dce74e98ba88c8b27be755dad59f10b53474 100644 (file)
@@ -159,7 +159,7 @@ static WERROR reg_dir_key_by_index(TALLOC_CTX *mem_ctx,
 {
        struct dirent *e;
        const struct dir_key *dk = talloc_get_type(k, struct dir_key);
-       int i = 0;
+       unsigned int i = 0;
        DIR *d;
 
        d = opendir(dk->path);
@@ -342,14 +342,14 @@ static WERROR reg_dir_get_value(TALLOC_CTX *mem_ctx,
 }
 
 static WERROR reg_dir_enum_value(TALLOC_CTX *mem_ctx,
-                                struct hive_key *key, int idx,
+                                struct hive_key *key, uint32_t idx,
                                 const char **name,
                                 uint32_t *type, DATA_BLOB *data)
 {
        const struct dir_key *dk = talloc_get_type(key, struct dir_key);
        DIR *d;
        struct dirent *e;
-       int i;
+       unsigned int i;
 
        d = opendir(dk->path);
        if (d == NULL) {
index 81ca2c39bcbdc41bb058a7574778ebbf23369f60..5d24f6da74baad69f5638e40b48e955095eb7189 100644 (file)
@@ -44,7 +44,7 @@ const struct reg_predefined_key reg_predefined_keys[] = {
 /** Obtain name of specific hkey. */
 _PUBLIC_ const char *reg_get_predef_name(uint32_t hkey)
 {
-       int i;
+       unsigned int i;
        for (i = 0; reg_predefined_keys[i].name; i++) {
                if (reg_predefined_keys[i].handle == hkey)
                        return reg_predefined_keys[i].name;
@@ -58,7 +58,7 @@ _PUBLIC_ WERROR reg_get_predefined_key_by_name(struct registry_context *ctx,
                                               const char *name,
                                               struct registry_key **key)
 {
-       int i;
+       unsigned int i;
 
        for (i = 0; reg_predefined_keys[i].name; i++) {
                if (!strcasecmp(reg_predefined_keys[i].name, name))
@@ -150,7 +150,7 @@ _PUBLIC_ WERROR reg_key_get_info(TALLOC_CTX *mem_ctx,
  */
 _PUBLIC_ WERROR reg_key_get_subkey_by_index(TALLOC_CTX *mem_ctx,
                                            const struct registry_key *key,
-                                           int idx, const char **name,
+                                           uint32_t idx, const char **name,
                                            const char **keyclass,
                                            NTTIME *last_changed_time)
 {
index 68639f5b5c1259e902f31533b0a61bd98999806d..8ed4b5d847ddd1200fc10e63f00268575a6a4866 100644 (file)
@@ -34,7 +34,7 @@ struct ldb_key_data
        struct ldb_context *ldb;
        struct ldb_dn *dn;
        struct ldb_message **subkeys, **values;
-       int subkey_count, value_count;
+       unsigned int subkey_count, value_count;
 };
 
 static void reg_ldb_unpack_value(TALLOC_CTX *mem_ctx, 
@@ -329,7 +329,7 @@ static WERROR ldb_get_default_value(TALLOC_CTX *mem_ctx, struct hive_key *k,
 }
 
 static WERROR ldb_get_value_by_id(TALLOC_CTX *mem_ctx, struct hive_key *k,
-                                 int idx, const char **name,
+                                 uint32_t idx, const char **name,
                                  uint32_t *data_type, DATA_BLOB *data)
 {
        struct ldb_key_data *kd = talloc_get_type(k, struct ldb_key_data);
@@ -572,7 +572,8 @@ static WERROR ldb_del_value (struct hive_key *key, const char *child)
 
 static WERROR ldb_del_key(const struct hive_key *key, const char *name)
 {
-       int i, ret;
+       unsigned int i;
+       int ret;
        struct ldb_key_data *parentkd = talloc_get_type(key, struct ldb_key_data);
        struct ldb_dn *ldap_path;
        TALLOC_CTX *mem_ctx = talloc_init("ldb_del_key");
@@ -711,7 +712,7 @@ static WERROR ldb_set_value(struct hive_key *parent,
 
        ret = ldb_add(kd->ldb, msg);
        if (ret == LDB_ERR_ENTRY_ALREADY_EXISTS) {
-               int i;
+               unsigned int i;
                for (i = 0; i < msg->num_elements; i++) {
                        if (msg->elements[i].flags != LDB_FLAG_MOD_DELETE)
                                msg->elements[i].flags = LDB_FLAG_MOD_REPLACE;
@@ -778,7 +779,7 @@ static WERROR ldb_get_key_info(TALLOC_CTX *mem_ctx,
 
 
        if (max_subkeynamelen != NULL) {
-               int i;
+               unsigned int i;
                struct ldb_message_element *el;
 
                *max_subkeynamelen = 0;
@@ -790,7 +791,7 @@ static WERROR ldb_get_key_info(TALLOC_CTX *mem_ctx,
        }
 
        if (max_valnamelen != NULL || max_valbufsize != NULL) {
-               int i;
+               unsigned int i;
                struct ldb_message_element *el;
                W_ERROR_NOT_OK_RETURN(cache_values(kd));
 
index a3aee06b1337f63a54e0020b47d22fa3c7bd1a24..458239b9e0353a3671cac1c74abbea348b000269 100644 (file)
@@ -167,7 +167,7 @@ static WERROR local_create_key(TALLOC_CTX *mem_ctx,
        struct local_key *local_parent;
        struct hive_key *hivekey;
        const char **elements;
-       int i;
+       unsigned int i;
        const char *last_part;
 
        last_part = strrchr(name, '\\');
@@ -328,7 +328,7 @@ WERROR reg_mount_hive(struct registry_context *rctx,
        struct registry_local *reg_local = talloc_get_type(rctx,
                                                           struct registry_local);
        struct mountpoint *mp = talloc(rctx, struct mountpoint);
-       int i = 0;
+       unsigned int i = 0;
 
        mp->path.predefined_key = key_id;
        mp->prev = mp->next = NULL;
index 0631e760cb9a6608fbef41839293761e7675567b..19e27f5837f8bc5e81e14a31b3a7c7b946a0d18a 100644 (file)
@@ -44,7 +44,7 @@ WERROR reg_generate_diff_key(struct registry_key *oldkey,
                             const struct reg_diff_callbacks *callbacks,
                             void *callback_data)
 {
-       int i;
+       unsigned int i;
        struct registry_key *t1 = NULL, *t2 = NULL;
        char *tmppath;
        const char *keyname1;
@@ -256,7 +256,7 @@ _PUBLIC_ WERROR reg_generate_diff(struct registry_context *ctx1,
                                  const struct reg_diff_callbacks *callbacks,
                                  void *callback_data)
 {
-       int i;
+       unsigned int i;
        WERROR error;
 
        for (i = 0; reg_predefined_keys[i].name; i++) {
index 5bc2335236e442a815071d8705705c2ce7245dd1..ddb917d15aaf69c18c4d41f90f80d28c6e0a306e 100644 (file)
@@ -64,7 +64,7 @@ struct regf_key_data {
 static struct hbin_block *hbin_by_offset(const struct regf_data *data,
                                         uint32_t offset, uint32_t *rel_offset)
 {
-       int i;
+       unsigned int i;
 
        for (i = 0; data->hbins[i]; i++) {
                if (offset >= data->hbins[i]->offset_from_first &&
@@ -86,7 +86,7 @@ static struct hbin_block *hbin_by_offset(const struct regf_data *data,
 static uint32_t regf_hdr_checksum(const uint8_t *buffer)
 {
        uint32_t checksum = 0, x;
-       int i;
+       unsigned int i;
 
        for (i = 0; i < 0x01FB; i+= 4) {
                x = IVAL(buffer, i);
@@ -161,7 +161,7 @@ static DATA_BLOB hbin_alloc(struct regf_data *data, uint32_t size,
        DATA_BLOB ret;
        uint32_t rel_offset = -1; /* Relative offset ! */
        struct hbin_block *hbin = NULL;
-       int i;
+       unsigned int i;
 
        *offset = 0;
 
@@ -340,7 +340,7 @@ static uint32_t hbin_store_resize(struct regf_data *data,
        int32_t orig_size;
        int32_t needed_size;
        int32_t possible_size;
-       int i;
+       unsigned int i;
 
        SMB_ASSERT(orig_offset > 0);
 
@@ -504,7 +504,7 @@ static struct regf_key_data *regf_get_key(TALLOC_CTX *ctx,
 
 
 static WERROR regf_get_value(TALLOC_CTX *ctx, struct hive_key *key,
-                            int idx, const char **name,
+                            uint32_t idx, const char **name,
                             uint32_t *data_type, DATA_BLOB *data)
 {
        const struct regf_key_data *private_data =
@@ -567,7 +567,7 @@ static WERROR regf_get_value_by_name(TALLOC_CTX *mem_ctx,
                                     struct hive_key *key, const char *name,
                                     uint32_t *type, DATA_BLOB *data)
 {
-       int i;
+       unsigned int i;
        const char *vname;
        WERROR error;
 
@@ -1551,7 +1551,7 @@ static WERROR regf_del_value (struct hive_key *key, const char *name)
        uint32_t vk_offset;
        bool found_offset = false;
        DATA_BLOB values;
-       uint32_t i;
+       unsigned int i;
 
        if (nk->values_offset == -1) {
                return WERR_BADFILE;
@@ -1627,7 +1627,7 @@ static WERROR regf_del_key(const struct hive_key *parent, const char *name)
        if (key->nk->subkeys_offset != -1) {
                char *sk_name;
                struct hive_key *sk = (struct hive_key *)key;
-               int i = key->nk->num_subkeys;
+               unsigned int i = key->nk->num_subkeys;
                while (i--) {
                        /* Get subkey information. */
                        error = regf_get_subkey_by_index(parent_nk, sk, 0,
@@ -1653,7 +1653,7 @@ static WERROR regf_del_key(const struct hive_key *parent, const char *name)
                char *val_name;
                struct hive_key *sk = (struct hive_key *)key;
                DATA_BLOB data;
-               int i = key->nk->num_values;
+               unsigned int i = key->nk->num_values;
                while (i--) {
                        /* Get value information. */
                        error = regf_get_value(parent_nk, sk, 0,
@@ -1878,7 +1878,7 @@ static WERROR regf_set_value(struct hive_key *key, const char *name,
 static WERROR regf_save_hbin(struct regf_data *regf)
 {
        struct tdr_push *push = tdr_push_init(regf, regf->iconv_convenience);
-       int i;
+       unsigned int i;
 
        W_ERROR_HAVE_NO_MEMORY(push);
 
@@ -2053,7 +2053,7 @@ WERROR reg_open_regf_file(TALLOC_CTX *parent_ctx, const char *location,
        struct regf_data *regf;
        struct regf_hdr *regf_hdr;
        struct tdr_pull *pull;
-       int i;
+       unsigned int i;
 
        regf = (struct regf_data *)talloc_zero(parent_ctx, struct regf_data);
 
index a97d9f61842d365378180d5d27b95ef609b39ec9..eeabaefb92ac0f279bb9b3e888fb8cdddfd6c8db 100644 (file)
@@ -88,7 +88,7 @@ struct hive_operations {
         * Retrieve a registry value with a specific index.
         */
        WERROR (*enum_value) (TALLOC_CTX *mem_ctx,
-                             struct hive_key *key, int idx,
+                             struct hive_key *key, uint32_t idx,
                              const char **name, uint32_t *type,
                              DATA_BLOB *data);
 
@@ -411,7 +411,7 @@ WERROR reg_key_get_info(TALLOC_CTX *mem_ctx,
                        uint32_t *max_valbufsize);
 WERROR reg_key_get_subkey_by_index(TALLOC_CTX *mem_ctx,
                                   const struct registry_key *key,
-                                  int idx,
+                                  uint32_t idx,
                                   const char **name,
                                   const char **classname,
                                   NTTIME *last_mod_time);
index 2bacaac6bc8f8ba8048acde4cea0957fd5079f33..003cbd15e07aaafab222cc573aaf6063929c73c9 100644 (file)
@@ -266,7 +266,7 @@ static WERROR cmd_print(struct regshell_context *ctx, int argc, char **argv)
 
 static WERROR cmd_ls(struct regshell_context *ctx, int argc, char **argv)
 {
-       int i;
+       unsigned int i;
        WERROR error;
        uint32_t valuetype;
        DATA_BLOB valuedata;
@@ -388,7 +388,7 @@ static struct {
 static WERROR cmd_help(struct regshell_context *ctx,
                       int argc, char **argv)
 {
-       int i;
+       unsigned int i;
        printf("Available commands:\n");
        for(i = 0; regshell_cmds[i].name; i++) {
                printf("%s - %s\n", regshell_cmds[i].name,
@@ -429,7 +429,8 @@ static char **reg_complete_command(const char *text, int start, int end)
 {
        /* Complete command */
        char **matches;
-       int i, len, samelen=0, count=1;
+       size_t len, samelen=0;
+       unsigned int i, count=1;
 
        matches = malloc_array_p(char *, MAX_COMPLETIONS);
        if (!matches) return NULL;
@@ -477,9 +478,8 @@ static char **reg_complete_key(const char *text, int start, int end)
 {
        struct registry_key *base;
        const char *subkeyname;
-       int i, j = 1;
-       int samelen = 0;
-       int len;
+       unsigned int i, j = 1;
+       size_t len, samelen = 0;
        char **matches;
        const char *base_n = "";
        TALLOC_CTX *mem_ctx;
@@ -593,7 +593,7 @@ int main(int argc, char **argv)
                return 1;
 
        if (ctx->current == NULL) {
-               int i;
+               unsigned int i;
 
                for (i = 0; (reg_predefined_keys[i].handle != 0) &&
                        (ctx->current == NULL); i++) {
index d266b604e31592cce440ab520827cb4ee6c122fc..72158283b3aa90857fa858fd22f61098f23e5a47 100644 (file)
@@ -43,7 +43,7 @@ static void print_tree(int level, struct registry_key *p,
        DATA_BLOB valuedata;
        struct security_descriptor *sec_desc;
        WERROR error;
-       int i;
+       unsigned int i;
        TALLOC_CTX *mem_ctx;
 
        for(i = 0; i < level; i++) putchar(' '); puts(name);
index ba739c4921afa5847b0ca2275b6a416dbe3039ca..8a4bc92fe1d8ffaeee620a410a0ebd1c8076e162 100644 (file)
@@ -41,7 +41,7 @@ static const struct {
 /** Return string description of registry value type */
 _PUBLIC_ const char *str_regtype(int type)
 {
-       int i;
+       unsigned int i;
        for (i = 0; reg_value_types[i].name; i++) {
                if (reg_value_types[i].id == type)
                        return reg_value_types[i].name;
@@ -115,7 +115,7 @@ _PUBLIC_ bool reg_string_to_val(TALLOC_CTX *mem_ctx,
                                const char *data_str, uint32_t *type,
                                DATA_BLOB *data)
 {
-       int i;
+       unsigned int i;
        *type = -1;
 
        /* Find the correct type */
@@ -171,7 +171,7 @@ WERROR reg_open_key_abs(TALLOC_CTX *mem_ctx, struct registry_context *handle,
 {
        struct registry_key *predef;
        WERROR error;
-       int predeflength;
+       size_t predeflength;
        char *predefname;
 
        if (strchr(name, '\\') != NULL)