s4:lib/registry: avoid some const warnings
[bbaumbach/samba-autobuild/.git] / source4 / lib / registry / tools / regtree.c
index 6d55a3eb84eac8e62f43205775357ebe6ad7b8ec..6df8e5067ec391f774e0aa517a492d6992064159 100644 (file)
@@ -33,7 +33,7 @@
  * @param fullpath Whether the full pat hshould be printed or just the last bit
  * @param novals Whether values should not be printed
  */
-static void print_tree(int level, struct registry_key *p,
+static void print_tree(unsigned int level, struct registry_key *p,
                       const char *name,
                       bool fullpath, bool novals)
 {
@@ -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);
@@ -55,18 +55,21 @@ static void print_tree(int level, struct registry_key *p,
                                                                      &keyname,
                                                                      NULL,
                                                                      NULL)); i++) {
-               SMB_ASSERT(strlen(keyname) > 0);
+
+               SMB_ASSERT(strlen(keyname) > 0);
                if (!W_ERROR_IS_OK(reg_open_key(mem_ctx, p, keyname, &subkey)))
-                       continue;
+                       continue;
+
                print_tree(level+1, subkey, (fullpath && strlen(name))?
-                                               talloc_asprintf(mem_ctx, "%s\\%s",
-                                                               name, keyname):
-                                               keyname, fullpath, novals);
+                                               talloc_asprintf(mem_ctx, "%s\\%s",
+                                                               name, keyname):
+                                               keyname, fullpath, novals);
+               talloc_free(subkey);
        }
        talloc_free(mem_ctx);
 
        if(!W_ERROR_EQUAL(error, WERR_NO_MORE_ITEMS)) {
-               DEBUG(0, ("Error occured while fetching subkeys for '%s': %s\n",
+               DEBUG(0, ("Error occurred while fetching subkeys for '%s': %s\n",
                                  name, win_errstr(error)));
        }
 
@@ -75,36 +78,36 @@ static void print_tree(int level, struct registry_key *p,
                for(i = 0; W_ERROR_IS_OK(error = reg_key_get_value_by_index(
                        mem_ctx, p, i, &valuename, &valuetype, &valuedata));
                        i++) {
-                       int j;
+                       unsigned int j;
                        for(j = 0; j < level+1; j++) putchar(' ');
                        printf("%s\n",  reg_val_description(mem_ctx,
-                               lp_iconv_convenience(cmdline_lp_ctx), valuename,
-                               valuetype, valuedata));
+                               valuename, valuetype, valuedata));
                }
                talloc_free(mem_ctx);
 
                if(!W_ERROR_EQUAL(error, WERR_NO_MORE_ITEMS)) {
-                       DEBUG(0, ("Error occured while fetching values for '%s': %s\n",
+                       DEBUG(0, ("Error occurred while fetching values for '%s': %s\n",
                                name, win_errstr(error)));
                }
        }
 
        mem_ctx = talloc_init("sec_desc");
-       if (NT_STATUS_IS_ERR(reg_get_sec_desc(mem_ctx, p, &sec_desc))) {
+       if (!W_ERROR_IS_OK(reg_get_sec_desc(mem_ctx, p, &sec_desc))) {
                DEBUG(0, ("Error getting security descriptor\n"));
        }
        talloc_free(mem_ctx);
 }
 
-int main(int argc, char **argv)
+int main(int argc, const char **argv)
 {
-       int opt, i;
+       int opt;
+       unsigned int i;
        const char *file = NULL;
        const char *remote = NULL;
        poptContext pc;
        struct registry_context *h = NULL;
        struct registry_key *start_key = NULL;
-       struct event_context *ev_ctx;
+       struct tevent_context *ev_ctx;
        WERROR error;
        bool fullpath = false, no_values = false;
        struct poptOption long_options[] = {
@@ -119,7 +122,7 @@ int main(int argc, char **argv)
                { NULL }
        };
 
-       pc = poptGetContext(argv[0], argc, (const char **) argv, long_options,0);
+       pc = poptGetContext(argv[0], argc, argv, long_options,0);
 
        while((opt = poptGetNextOpt(pc)) != -1) {
        }