From: Matthias Dieter Wallnöfer <mwallnoefer@yahoo.de>
Date: Sat, 26 Sep 2009 15:16:06 +0000 (+0200)
Subject: s3/s4 common: fix various warnings ("const" related ones)
X-Git-Url: http://repo.or.cz/w/Samba/mdw.git?a=commitdiff_plain;h=6376e555b54d4ad863f6c08be97a43bae9baca31

s3/s4 common: fix various warnings ("const" related ones)

I tried to add more "const"s to fix some of the warnings. Where this hasn't been
possible I added the "discard_const_p" macro.

Also I added some minor corrections.
---

diff --git a/client/mount.cifs.c b/client/mount.cifs.c
index 3baaad7..47a5175 100644
--- a/client/mount.cifs.c
+++ b/client/mount.cifs.c
@@ -76,7 +76,13 @@
 
 #define MAX_UNC_LEN 1024
 
-#define CONST_DISCARD(type, ptr)      ((type) ((void *) (ptr)))
+#ifndef discard_const
+#define discard_const(ptr) ((void *)((uintptr_t)(ptr)))
+#endif
+
+#ifndef discard_const_p
+#define discard_const_p(type, ptr) ((type *)discard_const(ptr))
+#endif
 
 #ifndef SAFE_FREE
 #define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
@@ -1638,7 +1644,7 @@ mount_retry:
 	}
 	mountent.mnt_fsname = dev_name;
 	mountent.mnt_dir = mountpoint;
-	mountent.mnt_type = CONST_DISCARD(char *,"cifs");
+	mountent.mnt_type = discard_const_p(char, "cifs");
 	mountent.mnt_opts = (char *)malloc(220);
 	if(mountent.mnt_opts) {
 		char * mount_user = getusername();
diff --git a/lib/tdb/tools/tdbdump.c b/lib/tdb/tools/tdbdump.c
index 8d93038..027fda3 100644
--- a/lib/tdb/tools/tdbdump.c
+++ b/lib/tdb/tools/tdbdump.c
@@ -65,8 +65,8 @@ static int dump_tdb(const char *fname, const char *keyname)
 	if (!keyname) {
 		tdb_traverse(tdb, traverse_fn, NULL);
 	} else {
-		key.dptr = discard_const_p(uint8_t,keyname);
-		key.dsize = strlen( keyname);
+		key.dptr = discard_const_p(uint8_t, keyname);
+		key.dsize = strlen(keyname);
 		value = tdb_fetch(tdb, key);
 		if (!value.dptr) {
 			return 1;
diff --git a/lib/tdb/tools/tdbtool.c b/lib/tdb/tools/tdbtool.c
index e469ceb..88924b6 100644
--- a/lib/tdb/tools/tdbtool.c
+++ b/lib/tdb/tools/tdbtool.c
@@ -27,6 +27,8 @@
 #include "system/wait.h"
 #include "tdb.h"
 
+#define SAFE_FREE(x) do { if ((x) != NULL) { free(x); x=NULL;} } while(0)
+
 static int do_command(void);
 const char *cmdname;
 char *arg1, *arg2;
@@ -290,7 +292,7 @@ static void show_tdb(char *keyname, size_t keylen)
 	
 	print_rec(tdb, key, dbuf, NULL);
 	
-	free( dbuf.dptr );
+	SAFE_FREE(dbuf.dptr);
 	
 	return;
 }
@@ -400,6 +402,7 @@ static void info_tdb(void)
 
 static void speed_tdb(const char *tlimit)
 {
+	const char *str = "store test", *str2 = "transaction test";
 	unsigned timelimit = tlimit?atoi(tlimit):0;
 	double t;
 	int ops;
@@ -411,9 +414,9 @@ static void speed_tdb(const char *tlimit)
 	do {
 		long int r = random();
 		TDB_DATA key, dbuf;
-		key.dptr = (unsigned char *)"store test";
+		key.dptr = discard_const_p(uint8_t, str);
 		key.dsize = strlen((char *)key.dptr);
-		dbuf.dptr = (unsigned char *)&r;
+		dbuf.dptr = (uint8_t *) &r;
 		dbuf.dsize = sizeof(r);
 		tdb_store(tdb, key, dbuf, TDB_REPLACE);
 		t = _end_timer();
@@ -427,9 +430,9 @@ static void speed_tdb(const char *tlimit)
 	do {
 		long int r = random();
 		TDB_DATA key, dbuf;
-		key.dptr = (unsigned char *)"store test";
+		key.dptr = discard_const_p(uint8_t, str);
 		key.dsize = strlen((char *)key.dptr);
-		dbuf.dptr = (unsigned char *)&r;
+		dbuf.dptr = (uint8_t *) &r;
 		dbuf.dsize = sizeof(r);
 		tdb_fetch(tdb, key);
 		t = _end_timer();
@@ -443,9 +446,9 @@ static void speed_tdb(const char *tlimit)
 	do {
 		long int r = random();
 		TDB_DATA key, dbuf;
-		key.dptr = (unsigned char *)"transaction test";
+		key.dptr = discard_const_p(uint8_t, str2);
 		key.dsize = strlen((char *)key.dptr);
-		dbuf.dptr = (unsigned char *)&r;
+		dbuf.dptr = (uint8_t *) &r;
 		dbuf.dsize = sizeof(r);
 		tdb_transaction_start(tdb);
 		tdb_store(tdb, key, dbuf, TDB_REPLACE);
diff --git a/lib/util/charset/tests/iconv.c b/lib/util/charset/tests/iconv.c
index 3e2546d..178192e 100644
--- a/lib/util/charset/tests/iconv.c
+++ b/lib/util/charset/tests/iconv.c
@@ -134,7 +134,7 @@ static bool test_buffer(struct torture_context *test,
 {
 	uint8_t buf1[1000], buf2[1000], buf3[1000];
 	size_t outsize1, outsize2, outsize3;
-	const char *ptr_in;
+	char *ptr_in;
 	char *ptr_out;
 	size_t size_in1, size_in2, size_in3;
 	size_t ret1, ret2, ret3, len1, len2;
@@ -164,25 +164,25 @@ static bool test_buffer(struct torture_context *test,
 	}
 
 	/* internal convert to charset - placing result in buf1 */
-	ptr_in = (const char *)inbuf;
+	ptr_in = (char *)inbuf;
 	ptr_out = (char *)buf1;
 	size_in1 = size;
 	outsize1 = sizeof(buf1);
 
 	memset(ptr_out, 0, outsize1);
 	errno = 0;
-	ret1 = smb_iconv(cd2, &ptr_in, &size_in1, &ptr_out, &outsize1);
+	ret1 = smb_iconv(cd2, (const char **) &ptr_in, &size_in1, &ptr_out, &outsize1);
 	errno1 = errno;
 
 	/* system convert to charset - placing result in buf2 */
-	ptr_in = (const char *)inbuf;
+	ptr_in = (char *)inbuf;
 	ptr_out = (char *)buf2;
 	size_in2 = size;
 	outsize2 = sizeof(buf2);
 	
 	memset(ptr_out, 0, outsize2);
 	errno = 0;
-	ret2 = iconv(cd, discard_const_p(char *, &ptr_in), &size_in2, &ptr_out, &outsize2);
+	ret2 = iconv(cd, &ptr_in, &size_in2, &ptr_out, &outsize2);
 	errno2 = errno;
 
 	len1 = sizeof(buf1) - outsize1;
@@ -236,13 +236,13 @@ static bool test_buffer(struct torture_context *test,
 
 	/* convert back to UTF-16, putting result in buf3 */
 	size = size - size_in1;
-	ptr_in = (const char *)buf1;
+	ptr_in = (char *)buf1;
 	ptr_out = (char *)buf3;
 	size_in3 = len1;
 	outsize3 = sizeof(buf3);
 
 	memset(ptr_out, 0, outsize3);
-	ret3 = smb_iconv(cd3, &ptr_in, &size_in3, &ptr_out, &outsize3);
+	ret3 = smb_iconv(cd3, (const char **) &ptr_in, &size_in3, &ptr_out, &outsize3);
 
 	/* we only internally support the first 1M codepoints */
 	if (outsize3 != sizeof(buf3) - size &&
diff --git a/lib/util/tests/strlist.c b/lib/util/tests/strlist.c
index 877b671..787bebc 100644
--- a/lib/util/tests/strlist.c
+++ b/lib/util/tests/strlist.c
@@ -29,7 +29,7 @@ struct test_list_element {
 	const char *list[5];
 };
 
-struct test_list_element test_lists_strings[] = {
+const struct test_list_element test_lists_strings[] = {
 	{
 		.list_as_string = "",
 		.list = { NULL }
@@ -62,7 +62,7 @@ struct test_list_element test_lists_strings[] = {
 	}
 };
 
-struct test_list_element test_lists_shell_strings[] = {
+const struct test_list_element test_lists_shell_strings[] = {
 	{
 		.list_as_string = "",
 		.list = { NULL }
@@ -98,18 +98,19 @@ struct test_list_element test_lists_shell_strings[] = {
 	}
 };
 
-static bool test_lists_shell(struct torture_context *tctx,
-			     const void *data)
+static bool test_lists_shell(struct torture_context *tctx, const void *data)
 {
-	const struct test_list_element *element = data;
-	const char **ret1, **ret2, *tmp;
+	const struct test_list_element *element =
+				(const struct test_list_element *) data;
+
+	char **ret1, **ret2, *tmp;
 	bool match = true;
 	TALLOC_CTX *mem_ctx = tctx;
 
 	ret1 = str_list_make_shell(mem_ctx, element->list_as_string, element->seperators);
 	
 	torture_assert(tctx, ret1, "str_list_make_shell() must not return NULL");
-	tmp = str_list_join_shell(mem_ctx, ret1, element->seperators ? *element->seperators : ' ');
+	tmp = str_list_join_shell(mem_ctx, (const char **) ret1, element->seperators ? *element->seperators : ' ');
 	ret2 = str_list_make_shell(mem_ctx, tmp, element->seperators);
 
 	if ((ret1 == NULL || ret2 == NULL) && ret2 != ret1) {
@@ -129,7 +130,8 @@ static bool test_lists_shell(struct torture_context *tctx,
 
 	torture_assert(tctx, match, talloc_asprintf(tctx, 
 		"str_list_{make,join}_shell: Error double parsing, first run:\n%s\nSecond run: \n%s", element->list_as_string, tmp));
-	torture_assert(tctx, str_list_equal(ret1, element->list), 
+	torture_assert(tctx, str_list_equal((const char * const *) ret1,
+					    element->list),
 		       talloc_asprintf(tctx, 
 				       "str_list_make_shell(%s) failed to create correct list", 
 				       element->list_as_string));
@@ -139,11 +141,14 @@ static bool test_lists_shell(struct torture_context *tctx,
 
 static bool test_list_make(struct torture_context *tctx, const void *data)
 {
-	const struct test_list_element *element = data;
+	const struct test_list_element *element =
+				(const struct test_list_element *) data;
+
 	char **result;
 	result = str_list_make(tctx, element->list_as_string, element->seperators);
 	torture_assert(tctx, result, "str_list_make() must not return NULL");
-	torture_assert(tctx, str_list_equal((const char **)result, element->list), 
+	torture_assert(tctx, str_list_equal((const char * const *) result,
+					    element->list),
 		       talloc_asprintf(tctx, 
 				       "str_list_make(%s) failed to create correct list", 
 				       element->list_as_string));
@@ -249,7 +254,7 @@ static bool test_list_length(struct torture_context *tctx)
 
 static bool test_list_add(struct torture_context *tctx)
 {
-	char **result, **result2;
+	const char **result, **result2;
 	const char *list[] = {
 		"element_0", 
 		"element_1",
@@ -257,9 +262,9 @@ static bool test_list_add(struct torture_context *tctx)
 		"element_3",
 		NULL
 	};
-	result = str_list_make(tctx, "element_0, element_1, element_2", NULL);
+	result = (const char **) str_list_make(tctx, "element_0, element_1, element_2", NULL);
 	torture_assert(tctx, result, "str_list_make() must not return NULL");
-	result2 = str_list_add(result, "element_3");
+	result2 = str_list_add((const char **) result, "element_3");
 	torture_assert(tctx, result2, "str_list_add() must not return NULL");
 	torture_assert(tctx, str_list_equal(result2, list), 
 		       "str_list_add() failed");
@@ -269,7 +274,7 @@ static bool test_list_add(struct torture_context *tctx)
 
 static bool test_list_add_const(struct torture_context *tctx)
 {
-	char **result, **result2;
+	const char **result, **result2;
 	const char *list[] = {
 		"element_0", 
 		"element_1",
@@ -277,7 +282,7 @@ static bool test_list_add_const(struct torture_context *tctx)
 		"element_3",
 		NULL
 	};
-	result = str_list_make(tctx, "element_0, element_1, element_2", NULL);
+	result = (const char **) str_list_make(tctx, "element_0, element_1, element_2", NULL);
 	torture_assert(tctx, result, "str_list_make() must not return NULL");
 	result2 = str_list_add_const(result, "element_3");
 	torture_assert(tctx, result2, "str_list_add_const() must not return NULL");
@@ -289,14 +294,14 @@ static bool test_list_add_const(struct torture_context *tctx)
 
 static bool test_list_remove(struct torture_context *tctx)
 {
-	char **result;
+	const char **result;
 	const char *list[] = {
 		"element_0", 
 		"element_1",
 		"element_3",
 		NULL
 	};
-	result = str_list_make(tctx, "element_0, element_1, element_2, element_3", NULL);
+	result = (const char **) str_list_make(tctx, "element_0, element_1, element_2, element_3", NULL);
 	torture_assert(tctx, result, "str_list_make() must not return NULL");
 	str_list_remove(result, "element_2");
 	torture_assert(tctx, str_list_equal(result, list), 
@@ -335,7 +340,7 @@ static bool test_list_check_ci(struct torture_context *tctx)
 
 static bool test_list_unique(struct torture_context *tctx)
 {
-	char **result;
+	const char **result;
 	const char *list[] = {
 		"element_0", 
 		"element_1",
@@ -353,7 +358,7 @@ static bool test_list_unique(struct torture_context *tctx)
 		"element_2",
 		NULL
 	};
-	result = str_list_copy(tctx, list_dup);
+	result = (const char **) str_list_copy(tctx, list_dup);
 	/* We must copy the list, as str_list_unique does a talloc_realloc() on it's parameter */
 	result = str_list_unique(result);
 	torture_assert(tctx, result, "str_list_unique() must not return NULL");
@@ -366,7 +371,7 @@ static bool test_list_unique(struct torture_context *tctx)
 
 static bool test_list_append(struct torture_context *tctx)
 {
-	char **result;
+	const char **result;
 	const char *list[] = {
 		"element_0", 
 		"element_1",
@@ -388,7 +393,7 @@ static bool test_list_append(struct torture_context *tctx)
 		"element_5",
 		NULL
 	};
-	result = str_list_copy(tctx, list);
+	result = (const char **) str_list_copy(tctx, list);
 	torture_assert(tctx, result, "str_list_copy() must not return NULL");
 	result = str_list_append(result, list2);
 	torture_assert(tctx, result, "str_list_append() must not return NULL");
@@ -400,7 +405,7 @@ static bool test_list_append(struct torture_context *tctx)
 
 static bool test_list_append_const(struct torture_context *tctx)
 {
-	char **result;
+	const char **result;
 	const char *list[] = {
 		"element_0", 
 		"element_1",
@@ -422,7 +427,7 @@ static bool test_list_append_const(struct torture_context *tctx)
 		"element_5",
 		NULL
 	};
-	result = str_list_copy(tctx, list);
+	result = (const char **) str_list_copy(tctx, list);
 	torture_assert(tctx, result, "str_list_copy() must not return NULL");
 	result = str_list_append_const(result, list2);
 	torture_assert(tctx, result, "str_list_append_const() must not return NULL");
@@ -439,12 +444,12 @@ struct torture_suite *torture_local_util_strlist(TALLOC_CTX *mem_ctx)
 
 	for (i = 0; i < ARRAY_SIZE(test_lists_shell_strings); i++) {
 		torture_suite_add_simple_tcase_const(suite, "lists_shell",
-				test_lists_shell, &test_lists_shell_strings[i]);
+			test_lists_shell,  &test_lists_shell_strings[i]);
 	}
 
 	for (i = 0; i < ARRAY_SIZE(test_lists_strings); i++) {
-		torture_suite_add_simple_tcase_const(suite, "lists",
-						     test_list_make, &test_lists_strings[i]);
+		torture_suite_add_simple_tcase_const(suite, "list_make",
+			test_list_make, &test_lists_strings[i]);
 	}
 
 	torture_suite_add_simple_test(suite, "list_copy", test_list_copy);
diff --git a/lib/util/util.h b/lib/util/util.h
index c766e3d..3ca9ee1 100644
--- a/lib/util/util.h
+++ b/lib/util/util.h
@@ -452,7 +452,7 @@ _PUBLIC_ char **str_list_copy(TALLOC_CTX *mem_ctx, const char **list);
 /**
    Return true if all the elements of the list match exactly.
  */
-_PUBLIC_ bool str_list_equal(const char **list1, const char **list2);
+_PUBLIC_ bool str_list_equal(const char * const *list1, const char * const *list2);
 
 /**
   add an entry to a string list
diff --git a/lib/util/util_strlist.c b/lib/util/util_strlist.c
index 1331fee..afbd2d9 100644
--- a/lib/util/util_strlist.c
+++ b/lib/util/util_strlist.c
@@ -264,7 +264,8 @@ _PUBLIC_ char **str_list_copy(TALLOC_CTX *mem_ctx, const char **list)
 /**
    Return true if all the elements of the list match exactly.
  */
-_PUBLIC_ bool str_list_equal(const char **list1, const char **list2)
+_PUBLIC_ bool str_list_equal(const char * const *list1,
+			     const char * const *list2)
 {
 	int i;
 	
diff --git a/libcli/named_pipe_auth/npa_tstream.c b/libcli/named_pipe_auth/npa_tstream.c
index 1c9ab8f..6d90f7e 100644
--- a/libcli/named_pipe_auth/npa_tstream.c
+++ b/libcli/named_pipe_auth/npa_tstream.c
@@ -66,7 +66,7 @@ struct tevent_req *tstream_npa_connect_send(TALLOC_CTX *mem_ctx,
 					const char *client_name_in,
 					const struct tsocket_address *server,
 					const char *server_name,
-					const struct netr_SamInfo3 *sam_info3,
+					struct netr_SamInfo3 *sam_info3,
 					DATA_BLOB session_key,
 					DATA_BLOB delegated_creds)
 {
@@ -143,7 +143,7 @@ struct tevent_req *tstream_npa_connect_send(TALLOC_CTX *mem_ctx,
 			info3->server_name = info3->server_addr;
 		}
 
-		info3->sam_info3 = discard_const_p(struct netr_SamInfo3, sam_info3);
+		info3->sam_info3 = sam_info3;
 		info3->session_key_length = session_key.length;
 		info3->session_key = session_key.data;
 		info3->gssapi_delegated_creds_length = delegated_creds.length;
diff --git a/libcli/named_pipe_auth/npa_tstream.h b/libcli/named_pipe_auth/npa_tstream.h
index bff010f..8266fa5 100644
--- a/libcli/named_pipe_auth/npa_tstream.h
+++ b/libcli/named_pipe_auth/npa_tstream.h
@@ -33,7 +33,7 @@ struct tevent_req *tstream_npa_connect_send(TALLOC_CTX *mem_ctx,
 					const char *client_name_in,
 					const struct tsocket_address *server,
 					const char *server_name,
-					const struct netr_SamInfo3 *info3,
+					struct netr_SamInfo3 *info3,
 					DATA_BLOB session_key,
 					DATA_BLOB delegated_creds);
 int _tstream_npa_connect_recv(struct tevent_req *req,
diff --git a/libcli/nbt/nbtname.c b/libcli/nbt/nbtname.c
index 338cb21..ff8ab2c 100644
--- a/libcli/nbt/nbtname.c
+++ b/libcli/nbt/nbtname.c
@@ -126,11 +126,11 @@ _PUBLIC_ enum ndr_err_code ndr_pull_nbt_string(struct ndr_pull *ndr, int ndr_fla
 				      "BAD NBT NAME too many components");
 	}
 	if (num_components == 0) {
-		name = talloc_strdup(ndr, "");
+		name = talloc_strdup(ndr->current_mem_ctx, "");
 		NDR_ERR_HAVE_NO_MEMORY(name);
 	}
 
-	(*s) = name;
+	(*s) = (const char *) name;
 	ndr->offset = max_offset;
 
 	return NDR_ERR_SUCCESS;
@@ -283,18 +283,21 @@ static uint8_t *compress_name(TALLOC_CTX *mem_ctx,
 */
 _PUBLIC_ enum ndr_err_code ndr_pull_nbt_name(struct ndr_pull *ndr, int ndr_flags, struct nbt_name *r)
 {
+	const char *cname_ret;
 	uint8_t *scope;
 	char *cname;
-	const char *s;
 	bool ok;
 
 	if (!(ndr_flags & NDR_SCALARS)) {
 		return NDR_ERR_SUCCESS;
 	}
 
-	NDR_CHECK(ndr_pull_nbt_string(ndr, ndr_flags, &s));
+	NDR_CHECK(ndr_pull_nbt_string(ndr, ndr_flags, &cname_ret));
 
-	scope = (uint8_t *)strchr(s, '.');
+	cname = talloc_strdup(ndr->current_mem_ctx, cname_ret);
+	NDR_ERR_HAVE_NO_MEMORY(cname);
+
+	scope = (uint8_t *)strchr(cname, '.');
 	if (scope) {
 		*scope = 0;
 		r->scope = talloc_strdup(ndr->current_mem_ctx, (const char *)&scope[1]);
@@ -303,8 +306,6 @@ _PUBLIC_ enum ndr_err_code ndr_pull_nbt_name(struct ndr_pull *ndr, int ndr_flags
 		r->scope = NULL;
 	}
 
-	cname = discard_const_p(char, s);
-
 	/* the first component is limited to 16 bytes in the DOS charset,
 	   which is 32 in the 'compressed' form */
 	if (strlen(cname) > 32) {
@@ -319,10 +320,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_nbt_name(struct ndr_pull *ndr, int ndr_flags
 				      "NBT NAME failed to decompress");
 	}
 
-	r->name = talloc_strdup(ndr->current_mem_ctx, cname);
-	NDR_ERR_HAVE_NO_MEMORY(r->name);
-
-	talloc_free(cname);
+	r->name = cname;
 
 	return NDR_ERR_SUCCESS;
 }
diff --git a/libgpo/gpext/gpext.c b/libgpo/gpext/gpext.c
index b6cc410..727470c 100644
--- a/libgpo/gpext/gpext.c
+++ b/libgpo/gpext/gpext.c
@@ -423,7 +423,7 @@ static WERROR gp_extension_store_reg_entry(TALLOC_CTX *mem_ctx,
 {
 	WERROR werr;
 	struct registry_key *key = NULL;
-	const char *subkeyname = NULL;
+	char *subkeyname = NULL;
 
 	if (!gp_extension_reg_info_verify(entry)) {
 		return WERR_INVALID_PARAM;
@@ -432,10 +432,10 @@ static WERROR gp_extension_store_reg_entry(TALLOC_CTX *mem_ctx,
 	subkeyname = GUID_string2(mem_ctx, &entry->guid);
 	W_ERROR_HAVE_NO_MEMORY(subkeyname);
 
-	strupper_m(CONST_DISCARD(char *,subkeyname));
+	strupper_m(subkeyname);
 
 	werr = gp_store_reg_subkey(mem_ctx,
-				   subkeyname,
+				   (const char *) subkeyname,
 				   reg_ctx->curr_key,
 				   &key);
 	W_ERROR_NOT_OK_RETURN(werr);
diff --git a/nsswitch/pam_winbind.c b/nsswitch/pam_winbind.c
index fdb5be3..d98167e 100644
--- a/nsswitch/pam_winbind.c
+++ b/nsswitch/pam_winbind.c
@@ -11,7 +11,6 @@
 */
 
 #include "pam_winbind.h"
-#define CONST_DISCARD(type,ptr) ((type)(void *)ptr)
 
 
 static int wbc_error_to_pam_error(wbcErr status)
@@ -412,51 +411,49 @@ static int _pam_parse(const pam_handle_t *pamh,
 		config_file = PAM_WINBIND_CONFIG_FILE;
 	}
 
-	d = iniparser_load(CONST_DISCARD(char *, config_file));
+	d = iniparser_load(config_file);
 	if (d == NULL) {
 		goto config_from_pam;
 	}
 
-	if (iniparser_getboolean(d, CONST_DISCARD(char *, "global:debug"), false)) {
+	if (iniparser_getboolean(d, "global:debug", false)) {
 		ctrl |= WINBIND_DEBUG_ARG;
 	}
 
-	if (iniparser_getboolean(d, CONST_DISCARD(char *, "global:debug_state"), false)) {
+	if (iniparser_getboolean(d, "global:debug_state", false)) {
 		ctrl |= WINBIND_DEBUG_STATE;
 	}
 
-	if (iniparser_getboolean(d, CONST_DISCARD(char *, "global:cached_login"), false)) {
+	if (iniparser_getboolean(d, "global:cached_login", false)) {
 		ctrl |= WINBIND_CACHED_LOGIN;
 	}
 
-	if (iniparser_getboolean(d, CONST_DISCARD(char *, "global:krb5_auth"), false)) {
+	if (iniparser_getboolean(d, "global:krb5_auth", false)) {
 		ctrl |= WINBIND_KRB5_AUTH;
 	}
 
-	if (iniparser_getboolean(d, CONST_DISCARD(char *, "global:silent"), false)) {
+	if (iniparser_getboolean(d, "global:silent", false)) {
 		ctrl |= WINBIND_SILENT;
 	}
 
-	if (iniparser_getstr(d, CONST_DISCARD(char *, "global:krb5_ccache_type")) != NULL) {
+	if (iniparser_getstr(d, "global:krb5_ccache_type") != NULL) {
 		ctrl |= WINBIND_KRB5_CCACHE_TYPE;
 	}
 
-	if ((iniparser_getstr(d, CONST_DISCARD(char *, "global:require-membership-of"))
-	     != NULL) ||
-	    (iniparser_getstr(d, CONST_DISCARD(char *, "global:require_membership_of"))
-	     != NULL)) {
+	if ((iniparser_getstr(d, "global:require-membership-of") != NULL) ||
+	    (iniparser_getstr(d, "global:require_membership_of") != NULL)) {
 		ctrl |= WINBIND_REQUIRED_MEMBERSHIP;
 	}
 
-	if (iniparser_getboolean(d, CONST_DISCARD(char *, "global:try_first_pass"), false)) {
+	if (iniparser_getboolean(d, "global:try_first_pass"), false) {
 		ctrl |= WINBIND_TRY_FIRST_PASS_ARG;
 	}
 
-	if (iniparser_getint(d, CONST_DISCARD(char *, "global:warn_pwd_expire"), 0)) {
+	if (iniparser_getint(d, "global:warn_pwd_expire"), 0) {
 		ctrl |= WINBIND_WARN_PWD_EXPIRE;
 	}
 
-	if (iniparser_getboolean(d, CONST_DISCARD(char *, "global:mkhomedir"), false)) {
+	if (iniparser_getboolean(d, "global:mkhomedir", false)) {
 		ctrl |= WINBIND_MKHOMEDIR;
 	}
 
