change --picky-developer into --non-picky-developer

Stefan (metze) Metzmacher metze at samba.org
Tue Nov 11 07:12:09 MST 2014


Hi Richard,

if you want review the following patchset.

The top 2 patches from
https://git.samba.org/?p=metze/samba/wip.git;a=shortlog;h=refs/heads/master4-picky
are not included because I haven't tested it with 'clang' instead of 'gcc'.
So in order force people using 'clang' to use '--disable-warnings-as-errors'
I just make sure that autobuild uses --picky-developer for now (when
building samba).

Thanks!
metze

Am 31.10.2014 um 11:48 schrieb Stefan (metze) Metzmacher:
> Am 31.10.2014 um 11:43 schrieb Andrew Bartlett:
>> On Thu, 2014-10-30 at 11:20 +0100, Stefan (metze) Metzmacher wrote:
>>> Am 30.10.2014 um 11:10 schrieb Stefan (metze) Metzmacher:
>>>> Hi Jelmer,
>>>>
>>>>>>> Ok, I fixed up
>>>>>>> https://git.samba.org/?p=metze/samba/wip.git;a=shortlog;h=refs/heads/master4-picky
>>>>>>
>>>>>> That looks better, and I'll keep looking over it.  Garming fixed some of
>>>>>> the same things in loadparm in his patch set, and I would like to get
>>>>>> this rebased on his changes, and both sets into master. 
>>>>>
>>>>> Can we make it --lenient-developer rather than --non-picky-developer ?
>>>>> :-)
>>>>
>>>> What about --disable-Werror ?
>>>
>>> Wireshark has:
>>>
>>>   --enable-warnings-as-errors
>>>                           treat warnings as errors (only for GCC or clang)
>>>                           [default=yes, unless extra compiler warnings are
>>>                           enabled]
>>>
>>> We could use --disable-warnings-as-errors ?
>>> Or just make use --disable-Werror
>>
>> I'm ok with --disable-warnings-as-errors, it makes no implication on the
>> developer just because they run a non-normative system.
> 
> Ok, I'll change it to --disable-warnings-as-errors.
> 
>> In terms of the rest of the patch, when I reviewed it last time, the
>> remaining patches were those that traded style or clarity for a warning,
>> or were not totally obvious as to what the change was.  I need to look
>> over it again, naturally. 
> 
> Thanks!
> 
>> Taken one at a time, the cure often feels worse than the illness but I
>> also accept that while these cases are not bugs, warnings can find bugs.
>> I also agree that the most subtle bugs lurk in code that *looks* correct
>> and sensible, and that warnings are too often overlooked. 
> 
> Yes, we should notice when warnings are added.
> 
>> I certainly hope we can work something out here, so that we both improve
>> our code and prevent regressions. 
> 
> Thanks!
> metze
> 
-------------- next part --------------
From 30e8ec4a167f28e4fa5e075a5049966789414809 Mon Sep 17 00:00:00 2001
From: Stefan Metzmacher <metze at samba.org>
Date: Fri, 7 Nov 2014 09:36:16 +0100
Subject: [PATCH 01/64] wafsamba: add -Werror=return-type for developer builds
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This avoids errors like this:

 ../source3/utils/status.c: In function ‘print_share_mode’:
 ../source3/utils/status.c:126:3: error: ‘return’ with no value, in function
 returning non-void [-Werror=return-type]
   return;

Signed-off-by: Stefan Metzmacher <metze at samba.org>
---
 buildtools/wafsamba/samba_autoconf.py | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/buildtools/wafsamba/samba_autoconf.py b/buildtools/wafsamba/samba_autoconf.py
index f60ce9d..c193873 100644
--- a/buildtools/wafsamba/samba_autoconf.py
+++ b/buildtools/wafsamba/samba_autoconf.py
@@ -671,6 +671,8 @@ def SAMBA_CONFIG_H(conf, path=None):
                         testflags=True)
         conf.ADD_CFLAGS('-Werror=declaration-after-statement -Wdeclaration-after-statement',
                         testflags=True)
+        conf.ADD_CFLAGS('-Werror=return-type -Wreturn-type',
+                        testflags=True)
 
         conf.ADD_CFLAGS('-Wformat=2 -Wno-format-y2k', testflags=True)
         # This check is because for ldb_search(), a NULL format string
-- 
1.9.1


From e678f0773b932df233ec93e54c2ae6751c729ac3 Mon Sep 17 00:00:00 2001
From: Stefan Metzmacher <metze at samba.org>
Date: Wed, 29 Oct 2014 11:48:59 +0100
Subject: [PATCH 02/64] lib/texpect: make the code more portable by using
 "replace.h" and "system/wait.h"

Signed-off-by: Stefan Metzmacher <metze at samba.org>
---
 lib/texpect/texpect.c | 17 ++---------------
 1 file changed, 2 insertions(+), 15 deletions(-)

diff --git a/lib/texpect/texpect.c b/lib/texpect/texpect.c
index ac88979..dcee3e1 100644
--- a/lib/texpect/texpect.c
+++ b/lib/texpect/texpect.c
@@ -31,20 +31,9 @@
  * SUCH DAMAGE.
  */
 
-#include "config.h"
+#include "replace.h"
+#include "system/wait.h"
 
-#ifndef HAVE_SYS_TYPES_H
-#include <sys/types.h>
-#endif
-#ifdef HAVE_SYS_WAIT_H
-#include <sys/wait.h>
-#endif
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
 #ifdef HAVE_PTY_H
 #include <pty.h>
 #endif
@@ -60,9 +49,7 @@
 #endif /* STREAMPTY */
 
 #include <popt.h>
-#include <errno.h>
 #include <err.h>
-#include <signal.h>
 
 struct command {
 	enum { CMD_EXPECT = 0, CMD_SEND, CMD_PASSWORD } type;
-- 
1.9.1


From 3fa6d3b8dc58e048473a7d51ff110d7c22657ade Mon Sep 17 00:00:00 2001
From: Stefan Metzmacher <metze at samba.org>
Date: Fri, 26 Sep 2014 09:06:59 +0200
Subject: [PATCH 03/64] lib/texpect: fix compiler warnings
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Stefan Metzmacher <metze at samba.org>
Reviewed-by: Günther Deschner <gd at samba.org>
---
 lib/texpect/texpect.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/lib/texpect/texpect.c b/lib/texpect/texpect.c
index dcee3e1..3640b67 100644
--- a/lib/texpect/texpect.c
+++ b/lib/texpect/texpect.c
@@ -357,8 +357,9 @@ int main(int argc, const char **argv)
 	pid_t pid;
 	poptContext pc;
 	const char *instruction_file;
+	const char **args;
 	const char *program;
-	char* const *program_args;
+	char * const *program_args;
 
 	pc = poptGetContext("texpect",
 			    argc,
@@ -376,7 +377,8 @@ int main(int argc, const char **argv)
 	}
 
 	instruction_file = poptGetArg(pc);
-	program_args = poptGetArgs(pc);
+	args = poptGetArgs(pc);
+	program_args = (char * const *)discard_const_p(char *, args);
 	program = program_args[0];
 
 	if (opt_verbose) {
-- 
1.9.1


From 1257a675535a801806c7077336453b2a8d446576 Mon Sep 17 00:00:00 2001
From: Stefan Metzmacher <metze at samba.org>
Date: Wed, 29 Oct 2014 11:52:37 +0100
Subject: [PATCH 04/64] lib/ldb: fix compiler warnings in
 ldb_modules_list_from_string()

Signed-off-by: Stefan Metzmacher <metze at samba.org>
---
 lib/ldb/common/ldb_modules.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/ldb/common/ldb_modules.c b/lib/ldb/common/ldb_modules.c
index 05a8d8a..91412a6 100644
--- a/lib/ldb/common/ldb_modules.c
+++ b/lib/ldb/common/ldb_modules.c
@@ -87,7 +87,7 @@ const char **ldb_modules_list_from_string(struct ldb_context *ldb, TALLOC_CTX *m
 
 	if (modstr[0] == '\0') {
 		modules[0] = NULL;
-		m = (const char **)modules;
+		m = discard_const_p(const char *, modules);
 		return m;
 	}
 
@@ -110,7 +110,7 @@ const char **ldb_modules_list_from_string(struct ldb_context *ldb, TALLOC_CTX *m
 
 	modules[i + 1] = NULL;
 
-	m = (const char **)modules;
+	m = discard_const_p(const char *, modules);
 
 	return m;
 }
-- 
1.9.1


From 00f15b4a37e49cff2c8314b08b158629efa7ae94 Mon Sep 17 00:00:00 2001
From: Stefan Metzmacher <metze at samba.org>
Date: Wed, 29 Oct 2014 11:53:06 +0100
Subject: [PATCH 05/64] lib/ldb: fix compiler warnings in ldb_tdb.c

Signed-off-by: Stefan Metzmacher <metze at samba.org>
---
 lib/ldb/ldb_tdb/ldb_tdb.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/lib/ldb/ldb_tdb/ldb_tdb.c b/lib/ldb/ldb_tdb/ldb_tdb.c
index d3c83f5..bcb8f0f 100644
--- a/lib/ldb/ldb_tdb/ldb_tdb.c
+++ b/lib/ldb/ldb_tdb/ldb_tdb.c
@@ -264,6 +264,7 @@ int ltdb_store(struct ldb_module *module, const struct ldb_message *msg, int flg
 	void *data = ldb_module_get_private(module);
 	struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private);
 	TDB_DATA tdb_key, tdb_data;
+	struct ldb_val ldb_data;
 	int ret = LDB_SUCCESS;
 
 	tdb_key = ltdb_key(module, msg->dn);
@@ -272,12 +273,15 @@ int ltdb_store(struct ldb_module *module, const struct ldb_message *msg, int flg
 	}
 
 	ret = ldb_pack_data(ldb_module_get_ctx(module),
-			    msg, (struct ldb_val *)&tdb_data);
+			    msg, &ldb_data);
 	if (ret == -1) {
 		talloc_free(tdb_key.dptr);
 		return LDB_ERR_OTHER;
 	}
 
+	tdb_data.dptr = ldb_data.data;
+	tdb_data.dsize = ldb_data.length;
+
 	ret = tdb_store(ltdb->tdb, tdb_key, tdb_data, flgs);
 	if (ret != 0) {
 		ret = ltdb_err_map(tdb_error(ltdb->tdb));
@@ -286,7 +290,7 @@ int ltdb_store(struct ldb_module *module, const struct ldb_message *msg, int flg
 
 done:
 	talloc_free(tdb_key.dptr);
-	talloc_free(tdb_data.dptr);
+	talloc_free(ldb_data.data);
 
 	return ret;
 }
@@ -673,6 +677,7 @@ int ltdb_modify_internal(struct ldb_module *module,
 	void *data = ldb_module_get_private(module);
 	struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private);
 	TDB_DATA tdb_key, tdb_data;
+	struct ldb_val ldb_data;
 	struct ldb_message *msg2;
 	unsigned int i, j, k;
 	int ret = LDB_SUCCESS, idx;
@@ -701,7 +706,10 @@ int ltdb_modify_internal(struct ldb_module *module,
 		goto done;
 	}
 
-	ret = ldb_unpack_data(ldb_module_get_ctx(module), (struct ldb_val *)&tdb_data, msg2);
+	ldb_data.data = tdb_data.dptr;
+	ldb_data.length = tdb_data.dsize;
+
+	ret = ldb_unpack_data(ldb_module_get_ctx(module), &ldb_data, msg2);
 	free(tdb_data.dptr);
 	if (ret == -1) {
 		ret = LDB_ERR_OTHER;
-- 
1.9.1


From 44ee5d92ada456fa8bb3ec6e041e583acb879dc9 Mon Sep 17 00:00:00 2001
From: Stefan Metzmacher <metze at samba.org>
Date: Wed, 29 Oct 2014 11:56:25 +0100
Subject: [PATCH 06/64] lib/ldb: remove unused 'allow_warnings=True'

Signed-off-by: Stefan Metzmacher <metze at samba.org>
---
 lib/ldb/wscript | 2 --
 1 file changed, 2 deletions(-)

diff --git a/lib/ldb/wscript b/lib/ldb/wscript
index 027c8cb..cb6b5c8 100755
--- a/lib/ldb/wscript
+++ b/lib/ldb/wscript
@@ -153,7 +153,6 @@ def build(bld):
                           pc_files='ldb.pc',
                           vnum=VERSION,
                           private_library=private_library,
-                          allow_warnings=True,
                           manpages='man/ldb.3',
                           abi_directory='ABI',
                           abi_match = abi_match)
@@ -255,7 +254,6 @@ def build(bld):
                             'common/ldb.c',
                             deps='tevent tdb',
                             includes='include',
-                            allow_warnings=True,
                             cflags=['-DLDB_MODULESDIR=\"%s\"' % modules_dir])
 
         LDB_TOOLS='ldbadd ldbsearch ldbdel ldbmodify ldbedit ldbrename'
-- 
1.9.1


From 029e8cd733e7ee39edf2292f0c72fe2ded6175ed Mon Sep 17 00:00:00 2001
From: Stefan Metzmacher <metze at samba.org>
Date: Wed, 29 Oct 2014 10:59:49 +0100
Subject: [PATCH 07/64] lib/util: add str_list_make_v3_const()

Signed-off-by: Stefan Metzmacher <metze at samba.org>
---
 lib/util/samba_util.h   | 4 ++++
 lib/util/util_strlist.c | 7 +++++++
 2 files changed, 11 insertions(+)

diff --git a/lib/util/samba_util.h b/lib/util/samba_util.h
index 41b3fc8..2f762ac 100644
--- a/lib/util/samba_util.h
+++ b/lib/util/samba_util.h
@@ -476,6 +476,10 @@ char **str_list_make_v3(TALLOC_CTX *mem_ctx, const char *string,
 	const char *sep);
 
 
+const char **str_list_make_v3_const(TALLOC_CTX *mem_ctx,
+				    const char *string,
+				    const char *sep);
+
 /* The following definitions come from lib/util/util_file.c  */
 
 
diff --git a/lib/util/util_strlist.c b/lib/util/util_strlist.c
index d0be917..9dd4ab3 100644
--- a/lib/util/util_strlist.c
+++ b/lib/util/util_strlist.c
@@ -588,3 +588,10 @@ char **str_list_make_v3(TALLOC_CTX *mem_ctx, const char *string,
 	TALLOC_FREE(s);
 	return list;
 }
+
+const char **str_list_make_v3_const(TALLOC_CTX *mem_ctx,
+				    const char *string,
+				    const char *sep)
+{
+	return const_str_list(str_list_make_v3(mem_ctx, string, sep));
+}
-- 
1.9.1


From 5b28c6bd092fa05bf6a0789fc31116e1a1a96c52 Mon Sep 17 00:00:00 2001
From: Stefan Metzmacher <metze at samba.org>
Date: Thu, 27 Feb 2014 09:35:15 +0100
Subject: [PATCH 08/64] lib/util/tests: avoid some compiler warnings

Signed-off-by: Stefan Metzmacher <metze at samba.org>
---
 lib/util/charset/tests/iconv.c | 19 ++++++++-------
 lib/util/tests/asn1_tests.c    | 22 +++++++++---------
 lib/util/tests/strlist.c       | 53 +++++++++++++++++++++++++++++++-----------
 3 files changed, 61 insertions(+), 33 deletions(-)

diff --git a/lib/util/charset/tests/iconv.c b/lib/util/charset/tests/iconv.c
index 06ace9b..30161d3 100644
--- a/lib/util/charset/tests/iconv.c
+++ b/lib/util/charset/tests/iconv.c
@@ -102,8 +102,10 @@ static unsigned int get_codepoint(char *buf, size_t size, const char *charset)
 	memset(out, 0, sizeof(out));
 
 	ret = iconv(cd, &buf, &size_in, &ptr_out, &size_out);
-
 	iconv_close(cd);
+	if (ret == (size_t) -1) {
+		return (unsigned int)-1;
+	}
 
 	return out[0] | (out[1]<<8) | (out[2]<<16) | (out[3]<<24);
 }
@@ -132,7 +134,8 @@ static bool test_buffer(struct torture_context *test,
 {
 	uint8_t buf1[1000], buf2[1000], buf3[1000];
 	size_t outsize1, outsize2, outsize3;
-	char *ptr_in;
+	const char *ptr_in1;
+	char *ptr_in2;
 	char *ptr_out;
 	size_t size_in1, size_in2, size_in3;
 	size_t ret1, ret2, ret3, len1, len2;
@@ -174,25 +177,25 @@ static bool test_buffer(struct torture_context *test,
 	}
 
 	/* internal convert to charset - placing result in buf1 */
-	ptr_in = (char *)inbuf;
+	ptr_in1 = (const char *)inbuf;
 	ptr_out = (char *)buf1;
 	size_in1 = size;
 	outsize1 = sizeof(buf1);
 
 	memset(ptr_out, 0, outsize1);
 	errno = 0;
-	ret1 = smb_iconv(cd2, (const char **) &ptr_in, &size_in1, &ptr_out, &outsize1);
+	ret1 = smb_iconv(cd2, &ptr_in1, &size_in1, &ptr_out, &outsize1);
 	errno1 = errno;
 
 	/* system convert to charset - placing result in buf2 */
-	ptr_in = (char *)inbuf;
+	ptr_in2 = (char *)inbuf;
 	ptr_out = (char *)buf2;
 	size_in2 = size;
 	outsize2 = sizeof(buf2);
 	
 	memset(ptr_out, 0, outsize2);
 	errno = 0;
-	ret2 = iconv(cd, &ptr_in, &size_in2, &ptr_out, &outsize2);
+	ret2 = iconv(cd, &ptr_in2, &size_in2, &ptr_out, &outsize2);
 	errno2 = errno;
 
 	len1 = sizeof(buf1) - outsize1;
@@ -247,13 +250,13 @@ static bool test_buffer(struct torture_context *test,
 
 	/* convert back to UTF-16, putting result in buf3 */
 	size = size - size_in1;
-	ptr_in = (char *)buf1;
+	ptr_in1 = (const char *)buf1;
 	ptr_out = (char *)buf3;
 	size_in3 = len1;
 	outsize3 = sizeof(buf3);
 
 	memset(ptr_out, 0, outsize3);
-	ret3 = smb_iconv(cd3, (const char **) &ptr_in, &size_in3, &ptr_out, &outsize3);
+	ret3 = smb_iconv(cd3, &ptr_in1, &size_in3, &ptr_out, &outsize3);
 
 	/* we only internally support the first 1M codepoints */
 	if (outsize3 != sizeof(buf3) - size &&
diff --git a/lib/util/tests/asn1_tests.c b/lib/util/tests/asn1_tests.c
index 2c68cb4..6dd7c64 100644
--- a/lib/util/tests/asn1_tests.c
+++ b/lib/util/tests/asn1_tests.c
@@ -111,47 +111,47 @@ static const struct {
 	int value;
 } integer_tests[] = {
         {
-		.blob = {"\x02\x01\x00", 3},
+		.blob = { discard_const_p(uint8_t, "\x02\x01\x00"), 3},
 		.value = 0
 	},
 	{
-		.blob = {"\x02\x01\x7f", 3},
+		.blob = { discard_const_p(uint8_t, "\x02\x01\x7f"), 3},
 		.value = 127
 	},
 	{
-		.blob = {"\x02\x02\x00\x80", 4},
+		.blob = { discard_const_p(uint8_t, "\x02\x02\x00\x80"), 4},
 		.value = 128
 	},
 	{
-		.blob = {"\x02\x02\x01\x00", 4},
+		.blob = { discard_const_p(uint8_t, "\x02\x02\x01\x00"), 4},
 		.value = 256
 	},
 	{
-		.blob = {"\x02\x01\x80", 3},
+		.blob = { discard_const_p(uint8_t, "\x02\x01\x80"), 3},
 		.value = -128
 	},
 	{
-		.blob = {"\x02\x02\xff\x7f", 4},
+		.blob = { discard_const_p(uint8_t, "\x02\x02\xff\x7f"), 4},
 		.value = -129
 	},
 	{
-		.blob = {"\x02\x01\xff", 3},
+		.blob = { discard_const_p(uint8_t, "\x02\x01\xff"), 3},
 		.value = -1
 	},
 	{
-		.blob = {"\x02\x02\xff\x01", 4},
+		.blob = { discard_const_p(uint8_t, "\x02\x02\xff\x01"), 4},
 		.value = -255
 	},
 	{
-		.blob = {"\x02\x02\x00\xff", 4},
+		.blob = { discard_const_p(uint8_t, "\x02\x02\x00\xff"), 4},
 		.value = 255
 	},
 	{
-		.blob = {"\x02\x04\x80\x00\x00\x00", 6},
+		.blob = { discard_const_p(uint8_t, "\x02\x04\x80\x00\x00\x00"), 6},
 		.value = 0x80000000
 	},
 	{
-		.blob = {"\x02\x04\x7f\xff\xff\xff", 6},
+		.blob = { discard_const_p(uint8_t, "\x02\x04\x7f\xff\xff\xff"), 6},
 		.value = 0x7fffffff
 	}
 };
diff --git a/lib/util/tests/strlist.c b/lib/util/tests/strlist.c
index 7df01d3..1718499 100644
--- a/lib/util/tests/strlist.c
+++ b/lib/util/tests/strlist.c
@@ -111,7 +111,8 @@ static bool test_lists_shell(struct torture_context *tctx, const void *data)
 	ret1 = str_list_make_shell(mem_ctx, element->list_as_string, element->separators);
 	
 	torture_assert(tctx, ret1, "str_list_make_shell() must not return NULL");
-	tmp = str_list_join_shell(mem_ctx, (const char **) ret1, element->separators ? *element->separators : ' ');
+	tmp = str_list_join_shell(mem_ctx, discard_const_p(const char *, ret1),
+				  element->separators ? *element->separators : ' ');
 	ret2 = str_list_make_shell(mem_ctx, tmp, element->separators);
 
 	if ((ret1 == NULL || ret2 == NULL) && ret2 != ret1) {
@@ -161,18 +162,22 @@ static bool test_list_copy(struct torture_context *tctx)
 	const char *list[] = { "foo", "bar", NULL };
 	const char *empty_list[] = { NULL };
 	const char **null_list = NULL;
+	char **l;
 
-	result = (const char **)str_list_copy(tctx, list);
+	l = str_list_copy(tctx, list);
+	result = discard_const_p(const char *, l);
 	torture_assert_int_equal(tctx, str_list_length(result), 2, "list length");
 	torture_assert_str_equal(tctx, result[0], "foo", "element 0");
 	torture_assert_str_equal(tctx, result[1], "bar", "element 1");
 	torture_assert_str_equal(tctx, result[2], NULL, "element 2");
 
-	result = (const char **)str_list_copy(tctx, empty_list);
+	l = str_list_copy(tctx, empty_list);
+	result = discard_const_p(const char *, l);
 	torture_assert_int_equal(tctx, str_list_length(result), 0, "list length");
 	torture_assert_str_equal(tctx, result[0], NULL, "element 0");
 
-	result = (const char **)str_list_copy(tctx, null_list);
+	l = str_list_copy(tctx, null_list);
+	result = discard_const_p(const char *, l);
 	torture_assert(tctx, result == NULL, "result NULL");
 	
 	return true;
@@ -262,9 +267,12 @@ static bool test_list_add(struct torture_context *tctx)
 		"element_3",
 		NULL
 	};
-	result = (const char **) str_list_make(tctx, "element_0, element_1, element_2", NULL);
+	char **l;
+
+	l = str_list_make(tctx, "element_0, element_1, element_2", NULL);
+	result = discard_const_p(const char *, l);
 	torture_assert(tctx, result, "str_list_make() must not return NULL");
-	result2 = str_list_add((const char **) result, "element_3");
+	result2 = str_list_add(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");
@@ -282,7 +290,10 @@ static bool test_list_add_const(struct torture_context *tctx)
 		"element_3",
 		NULL
 	};
-	result = (const char **) str_list_make(tctx, "element_0, element_1, element_2", NULL);
+	char **l;
+
+	l = str_list_make(tctx, "element_0, element_1, element_2", NULL);
+	result = discard_const_p(const char *, l);
 	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");
@@ -301,7 +312,10 @@ static bool test_list_remove(struct torture_context *tctx)
 		"element_3",
 		NULL
 	};
-	result = (const char **) str_list_make(tctx, "element_0, element_1, element_2, element_3", NULL);
+	char **l;
+
+	l = str_list_make(tctx, "element_0, element_1, element_2, element_3", NULL);
+	result = discard_const_p(const char *, l);
 	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), 
@@ -358,7 +372,10 @@ static bool test_list_unique(struct torture_context *tctx)
 		"element_2",
 		NULL
 	};
-	result = (const char **) str_list_copy(tctx, list_dup);
+	char **l;
+
+	l = str_list_copy(tctx, list_dup);
+	result = discard_const_p(const char *, l);
 	/* 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");
@@ -374,8 +391,11 @@ static bool test_list_unique_2(struct torture_context *tctx)
 	int i;
 	int count, num_dups;
 	const char **result;
-	const char **list = (const char **)str_list_make_empty(tctx);
-	const char **list_dup = (const char **)str_list_make_empty(tctx);
+	char **l1 = str_list_make_empty(tctx);
+	char **l2 = str_list_make_empty(tctx);
+	const char **list = discard_const_p(const char *, l1);
+	const char **list_dup = discard_const_p(const char *, l2);
+	char **l;
 
 	count = lpcfg_parm_int(tctx->lp_ctx, NULL, "list_unique", "count", 9);
 	num_dups = lpcfg_parm_int(tctx->lp_ctx, NULL, "list_unique", "dups", 7);
@@ -389,7 +409,8 @@ static bool test_list_unique_2(struct torture_context *tctx)
 		list_dup = str_list_append(list_dup, list);
 	}
 
-	result = (const char **)str_list_copy(tctx, list_dup);
+	l = str_list_copy(tctx, list_dup);
+	result = discard_const_p(const char *, l);
 	/* 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");
@@ -424,7 +445,9 @@ static bool test_list_append(struct torture_context *tctx)
 		"element_5",
 		NULL
 	};
-	result = (const char **) str_list_copy(tctx, list);
+	char **l;
+	l = str_list_copy(tctx, list);
+	result = discard_const_p(const char *, l);
 	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");
@@ -458,7 +481,9 @@ static bool test_list_append_const(struct torture_context *tctx)
 		"element_5",
 		NULL
 	};
-	result = (const char **) str_list_copy(tctx, list);
+	char **l;
+	l = str_list_copy(tctx, list);
+	result = discard_const_p(const char *, l);
 	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");
-- 
1.9.1


From f9120711d7816bd63c2967d1933184f2fb905053 Mon Sep 17 00:00:00 2001
From: Stefan Metzmacher <metze at samba.org>
Date: Wed, 26 Feb 2014 08:07:47 +0100
Subject: [PATCH 09/64] lib/param: fix const warnings

Signed-off-by: Stefan Metzmacher <metze at samba.org>
---
 lib/param/loadparm.c | 23 ++++++++++++-----------
 1 file changed, 12 insertions(+), 11 deletions(-)

diff --git a/lib/param/loadparm.c b/lib/param/loadparm.c
index d1e36df..b9a3e20 100644
--- a/lib/param/loadparm.c
+++ b/lib/param/loadparm.c
@@ -414,8 +414,10 @@ const char **lpcfg_parm_string_list(TALLOC_CTX *mem_ctx,
 {
 	const char *value = lpcfg_get_parametric(lp_ctx, service, type, option);
 
-	if (value != NULL)
-		return (const char **)str_list_make(mem_ctx, value, separator);
+	if (value != NULL) {
+		char **l = str_list_make(mem_ctx, value, separator);
+		return discard_const_p(const char *, l);
+	}
 
 	return NULL;
 }
@@ -905,8 +907,8 @@ void copy_service(struct loadparm_service *pserviceDest,
 				case P_CMDLIST:
 				case P_LIST:
 					TALLOC_FREE(*((char ***)dest_ptr));
-					*(const char * const **)dest_ptr = (const char * const *)str_list_copy(pserviceDest,
-										  *(const char * * const *)src_ptr);
+					*(char ***)dest_ptr = str_list_copy(pserviceDest,
+									    *discard_const_p(const char **, src_ptr));
 					break;
 				default:
 					break;
@@ -1287,8 +1289,8 @@ bool handle_netbios_aliases(struct loadparm_context *lp_ctx, struct loadparm_ser
 			    const char *pszParmValue, char **ptr)
 {
 	TALLOC_FREE(lp_ctx->globals->netbios_aliases);
-	lp_ctx->globals->netbios_aliases = (const char **)str_list_make_v3(lp_ctx->globals->ctx,
-									   pszParmValue, NULL);
+	lp_ctx->globals->netbios_aliases = str_list_make_v3_const(lp_ctx->globals->ctx,
+								  pszParmValue, NULL);
 
 	if (lp_ctx->s3_fns) {
 		return lp_ctx->s3_fns->set_netbios_aliases(lp_ctx->globals->netbios_aliases);
@@ -1502,9 +1504,8 @@ static bool set_variable_helper(TALLOC_CTX *mem_ctx, int parmnum, void *parm_ptr
 
 		case P_CMDLIST:
 			TALLOC_FREE(*(char ***)parm_ptr);
-			*(const char * const **)parm_ptr
-				= (const char * const *)str_list_make_v3(mem_ctx,
-									 pszParmValue, NULL);
+			*(char ***)parm_ptr = str_list_make_v3(mem_ctx,
+							pszParmValue, NULL);
 			break;
 
 		case P_LIST:
@@ -1537,7 +1538,7 @@ static bool set_variable_helper(TALLOC_CTX *mem_ctx, int parmnum, void *parm_ptr
 							  pszParmName, pszParmValue));
 						return false;
 					}
-					*(const char * const **)parm_ptr = (const char * const *) new_list;
+					*(char ***)parm_ptr = new_list;
 					break;
 				}
 			}
@@ -2001,7 +2002,7 @@ static bool is_default(void *base_structure, int i)
 		case P_CMDLIST:
 		case P_LIST:
 			return str_list_equal((const char * const *)parm_table[i].def.lvalue,
-					      *(const char ***)def_ptr);
+					      *(const char * const **)def_ptr);
 		case P_STRING:
 		case P_USTRING:
 			return strequal(parm_table[i].def.svalue,
-- 
1.9.1


From 208a900ca9da1d56bad4de3c418eab54e95cd97b Mon Sep 17 00:00:00 2001
From: Stefan Metzmacher <metze at samba.org>
Date: Thu, 27 Feb 2014 09:31:42 +0100
Subject: [PATCH 10/64] lib/smbconf: remove const warning

Signed-off-by: Stefan Metzmacher <metze at samba.org>
---
 lib/smbconf/smbconf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/smbconf/smbconf.c b/lib/smbconf/smbconf.c
index 27d36ca..4129ea5 100644
--- a/lib/smbconf/smbconf.c
+++ b/lib/smbconf/smbconf.c
@@ -286,7 +286,7 @@ sbcErr smbconf_create_set_share(struct smbconf_ctx *ctx,
 	}
 
 	err = smbconf_set_includes(ctx, service->name, num_includes,
-				   (const char **)includes);
+				   discard_const_p(const char *, includes));
 	if (!SBC_ERROR_IS_OK(err)) {
 		goto cancel;
 	}
-- 
1.9.1


From 45b063b964c340fa28f8420fedc6f51a35eca97f Mon Sep 17 00:00:00 2001
From: Stefan Metzmacher <metze at samba.org>
Date: Wed, 29 Oct 2014 11:57:10 +0100
Subject: [PATCH 11/64] librpc/ndr: add NDR_SCALAR_PTR_PROTO() helper macro

Signed-off-by: Stefan Metzmacher <metze at samba.org>
---
 librpc/ndr/libndr.h | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/librpc/ndr/libndr.h b/librpc/ndr/libndr.h
index 76b58bb..ee3fac6 100644
--- a/librpc/ndr/libndr.h
+++ b/librpc/ndr/libndr.h
@@ -556,6 +556,11 @@ enum ndr_err_code ndr_push_ ## name(struct ndr_push *ndr, int ndr_flags, type v)
 enum ndr_err_code ndr_pull_ ## name(struct ndr_pull *ndr, int ndr_flags, type *v); \
 void ndr_print_ ## name(struct ndr_print *ndr, const char *var_name, type v); 
 
+#define NDR_SCALAR_PTR_PROTO(name, type) \
+enum ndr_err_code ndr_push_ ## name(struct ndr_push *ndr, int ndr_flags, const type *v); \
+enum ndr_err_code ndr_pull_ ## name(struct ndr_pull *ndr, int ndr_flags, type **v); \
+void ndr_print_ ## name(struct ndr_print *ndr, const char *var_name, const type *v);
+
 #define NDR_BUFFER_PROTO(name, type) \
 enum ndr_err_code ndr_push_ ## name(struct ndr_push *ndr, int ndr_flags, const type *v); \
 enum ndr_err_code ndr_pull_ ## name(struct ndr_pull *ndr, int ndr_flags, type *v); \
-- 
1.9.1


From d3995cd5f5baf0caeb27fd66b6475fa0e9b73a12 Mon Sep 17 00:00:00 2001
From: Stefan Metzmacher <metze at samba.org>
Date: Wed, 29 Oct 2014 11:57:41 +0100
Subject: [PATCH 12/64] libcli/nbt: use NDR_SCALAR_PTR_PROTO() and fix the
 prototype of ndr_pull_wrepl_nbt_name()

This avoids compiler warnings in pidl generated code.

Signed-off-by: Stefan Metzmacher <metze at samba.org>
---
 libcli/nbt/libnbt.h  | 2 +-
 libcli/nbt/nbtname.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/libcli/nbt/libnbt.h b/libcli/nbt/libnbt.h
index 5a29a02..e6d7a98 100644
--- a/libcli/nbt/libnbt.h
+++ b/libcli/nbt/libnbt.h
@@ -333,7 +333,7 @@ NTSTATUS nbt_name_reply_send(struct nbt_name_socket *nbtsock,
 			     struct nbt_name_packet *request);
 
 
-NDR_SCALAR_PROTO(wrepl_nbt_name, const struct nbt_name *)
+NDR_SCALAR_PTR_PROTO(wrepl_nbt_name, struct nbt_name)
 NDR_BUFFER_PROTO(nbt_name, struct nbt_name)
 NTSTATUS nbt_rcode_to_ntstatus(uint8_t rcode);
 
diff --git a/libcli/nbt/nbtname.c b/libcli/nbt/nbtname.c
index 5be7830..d73dde1 100644
--- a/libcli/nbt/nbtname.c
+++ b/libcli/nbt/nbtname.c
@@ -324,7 +324,7 @@ _PUBLIC_ char *nbt_name_string(TALLOC_CTX *mem_ctx, const struct nbt_name *name)
 /**
   pull a nbt name, WINS Replication uses another on wire format for nbt name
 */
-_PUBLIC_ enum ndr_err_code ndr_pull_wrepl_nbt_name(struct ndr_pull *ndr, int ndr_flags, const struct nbt_name **_r)
+_PUBLIC_ enum ndr_err_code ndr_pull_wrepl_nbt_name(struct ndr_pull *ndr, int ndr_flags, struct nbt_name **_r)
 {
 	struct nbt_name *r;
 	uint8_t *namebuf;
-- 
1.9.1


From 0c85ba62b6734ce1ee887bc0e575cfece0b11e9d Mon Sep 17 00:00:00 2001
From: Stefan Metzmacher <metze at samba.org>
Date: Wed, 29 Oct 2014 12:00:12 +0100
Subject: [PATCH 13/64] s4:librpc: remove unused allow_warnings=True from
 NDR_WINSREPL and NDR_WINSIF

Signed-off-by: Stefan Metzmacher <metze at samba.org>
---
 source4/librpc/wscript_build | 2 --
 1 file changed, 2 deletions(-)

diff --git a/source4/librpc/wscript_build b/source4/librpc/wscript_build
index 8aaa0c9..15ba914 100755
--- a/source4/librpc/wscript_build
+++ b/source4/librpc/wscript_build
@@ -27,7 +27,6 @@ bld.SAMBA_SUBSYSTEM('NDR_SASL_HELPERS',
 
 bld.SAMBA_SUBSYSTEM('NDR_WINSIF',
 	source='gen_ndr/ndr_winsif.c',
-	allow_warnings=True,
 	public_deps='ndr'
 	)
 
@@ -46,7 +45,6 @@ bld.SAMBA_SUBSYSTEM('NDR_NTP_SIGND',
 
 bld.SAMBA_SUBSYSTEM('NDR_WINSREPL',
 	source='gen_ndr/ndr_winsrepl.c',
-	allow_warnings=True,
 	public_deps='ndr ndr_nbt'
 	)
 
-- 
1.9.1


From 1a19f2d2b4319a995f7819df861a1cc6d9017fa5 Mon Sep 17 00:00:00 2001
From: Stefan Metzmacher <metze at samba.org>
Date: Wed, 29 Oct 2014 12:03:15 +0100
Subject: [PATCH 14/64] s4:librpc/idl: add a uuid to sasl_helpers.idl

This makes it possible to use decode_saslauthd in ndrdump.

Signed-off-by: Stefan Metzmacher <metze at samba.org>
---
 source4/librpc/idl/sasl_helpers.idl | 2 ++
 source4/librpc/wscript_build        | 1 -
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/source4/librpc/idl/sasl_helpers.idl b/source4/librpc/idl/sasl_helpers.idl
index 8fa4b57..344d491 100644
--- a/source4/librpc/idl/sasl_helpers.idl
+++ b/source4/librpc/idl/sasl_helpers.idl
@@ -1,6 +1,8 @@
 #include "idl_types.h"
 
 [
+  uuid("7512b2f4-5f4f-11e4-bbe6-3c970e8d8226"),
+  version(1.0),
   pointer_default(unique),
   helpstring("SASL helpers")
 ]
diff --git a/source4/librpc/wscript_build b/source4/librpc/wscript_build
index 15ba914..ea81d2c 100755
--- a/source4/librpc/wscript_build
+++ b/source4/librpc/wscript_build
@@ -19,7 +19,6 @@ bld.SAMBA_SUBSYSTEM('NDR_IRPC',
 
 bld.SAMBA_SUBSYSTEM('NDR_SASL_HELPERS',
 	source='gen_ndr/ndr_sasl_helpers.c',
-	allow_warnings=True,
 	public_deps='ndr'
 	)
 
-- 
1.9.1


From c58c145b4089f38b980e2fa941e5e41f611bb293 Mon Sep 17 00:00:00 2001
From: Stefan Metzmacher <metze at samba.org>
Date: Thu, 22 May 2014 10:36:41 +0200
Subject: [PATCH 15/64] auth: add missing includes to auth/wbc_auth_util.c

Signed-off-by: Stefan Metzmacher <metze at samba.org>
---
 auth/wbc_auth_util.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/auth/wbc_auth_util.c b/auth/wbc_auth_util.c
index ebd24a9..1c50b18 100644
--- a/auth/wbc_auth_util.c
+++ b/auth/wbc_auth_util.c
@@ -21,6 +21,8 @@
 #include "libcli/security/security.h"
 #include "librpc/gen_ndr/netlogon.h"
 #include "nsswitch/libwbclient/wbclient.h"
+#include "librpc/gen_ndr/auth.h"
+#include "auth/auth_sam_reply.h"
 
 #undef DBGC_CLASS
 #define DBGC_CLASS DBGC_AUTH
-- 
1.9.1


From 402b7a1c68fe88ee5b9343ab577a54b8a077ff21 Mon Sep 17 00:00:00 2001
From: Stefan Metzmacher <metze at samba.org>
Date: Thu, 27 Feb 2014 09:38:39 +0100
Subject: [PATCH 16/64] nsswitch: avoid some compiler warnings

Signed-off-by: Stefan Metzmacher <metze at samba.org>
---
 nsswitch/pam_winbind.c       | 4 ++--
 nsswitch/wbinfo.c            | 7 ++++---
 nsswitch/winbind_nss_linux.c | 2 +-
 3 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/nsswitch/pam_winbind.c b/nsswitch/pam_winbind.c
index 564f773..f06f2b5 100644
--- a/nsswitch/pam_winbind.c
+++ b/nsswitch/pam_winbind.c
@@ -663,7 +663,7 @@ static int converse(const pam_handle_t *pamh,
 	retval = pam_get_item(pamh, PAM_CONV, (const void **) &conv);
 	if (retval == PAM_SUCCESS) {
 		retval = conv->conv(nargs,
-				    (const struct pam_message **)message,
+				    discard_const_p(const struct pam_message *, message),
 				    response, conv->appdata_ptr);
 	}
 
@@ -1998,7 +1998,7 @@ static int winbind_chauthtok_request(struct pwb_context *ctx,
 		}
 
 		/* FIXME: avoid to send multiple PAM messages after another */
-		switch (reject_reason) {
+		switch ((int)reject_reason) {
 			case -1:
 				break;
 			case WBC_PWD_CHANGE_NO_ERROR:
diff --git a/nsswitch/wbinfo.c b/nsswitch/wbinfo.c
index a31fbdf..9e06fb2 100644
--- a/nsswitch/wbinfo.c
+++ b/nsswitch/wbinfo.c
@@ -1329,13 +1329,14 @@ static bool wbinfo_lookuprids(const char *domain, const char *arg)
 	}
 
 	wbc_status = wbcLookupRids(&dinfo->sid, num_rids, rids,
-				   (const char **)&domain_name, &names, &types);
+				   &p, &names, &types);
 	if (!WBC_ERROR_IS_OK(wbc_status)) {
 		d_printf("winbind_lookup_rids failed: %s\n",
 			 wbcErrorString(wbc_status));
 		goto done;
 	}
 
+	domain_name = discard_const_p(char, p);
 	d_printf("Domain: %s\n", domain_name);
 
 	for (i=0; i<num_rids; i++) {
@@ -2104,7 +2105,7 @@ enum {
 	OPT_KRB5CCNAME
 };
 
-int main(int argc, char **argv, char **envp)
+int main(int argc, const char **argv, char **envp)
 {
 	int opt;
 	TALLOC_CTX *frame = talloc_stackframe();
@@ -2219,7 +2220,7 @@ int main(int argc, char **argv, char **envp)
 
 	/* Parse options */
 
-	pc = poptGetContext("wbinfo", argc, (const char **)argv,
+	pc = poptGetContext("wbinfo", argc, argv,
 			    long_options, 0);
 
 	/* Parse command line options */
diff --git a/nsswitch/winbind_nss_linux.c b/nsswitch/winbind_nss_linux.c
index 70ede3e..9afa9d4 100644
--- a/nsswitch/winbind_nss_linux.c
+++ b/nsswitch/winbind_nss_linux.c
@@ -287,7 +287,7 @@ static NSS_STATUS fill_pwent(struct passwd *result,
    Return NSS_STATUS_TRYAGAIN if we run out of memory. */
 
 static NSS_STATUS fill_grent(struct group *result, struct winbindd_gr *gr,
-		      char *gr_mem, char **buffer, size_t *buflen)
+		      const char *gr_mem, char **buffer, size_t *buflen)
 {
 	char *name;
 	int i;
-- 
1.9.1


From d6037647073270afcc6fd5aeda4c6001faf23809 Mon Sep 17 00:00:00 2001
From: Stefan Metzmacher <metze at samba.org>
Date: Wed, 26 Feb 2014 20:16:26 +0100
Subject: [PATCH 17/64] s3:auth: add missing auth_samba4_init() prototype

Signed-off-by: Stefan Metzmacher <metze at samba.org>
---
 source3/auth/proto.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/source3/auth/proto.h b/source3/auth/proto.h
index 1da0c44..9f4e47a 100644
--- a/source3/auth/proto.h
+++ b/source3/auth/proto.h
@@ -380,5 +380,8 @@ NTSTATUS make_session_info_krb5(TALLOC_CTX *mem_ctx,
 				DATA_BLOB *session_key,
 				struct auth_session_info **session_info);
 
+/* The following definitions come from auth/auth_samba4.c  */
+
+NTSTATUS auth_samba4_init(void);
 
 #endif /* _AUTH_PROTO_H_ */
-- 
1.9.1


From 8b2a796d6cdda7303cc1b8338084348da3a231cc Mon Sep 17 00:00:00 2001
From: Stefan Metzmacher <metze at samba.org>
Date: Wed, 26 Feb 2014 20:16:26 +0100
Subject: [PATCH 18/64] s3:auth: add some const to user_in_list()

Signed-off-by: Stefan Metzmacher <metze at samba.org>
---
 source3/auth/proto.h     | 2 +-
 source3/auth/user_util.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/source3/auth/proto.h b/source3/auth/proto.h
index 9f4e47a..da3c099 100644
--- a/source3/auth/proto.h
+++ b/source3/auth/proto.h
@@ -356,7 +356,7 @@ void debug_unix_user_token(int dbg_class, int dbg_lev, uid_t uid, gid_t gid,
 
 bool map_username(TALLOC_CTX *ctx, const char *user_in, char **p_user_out);
 bool user_in_netgroup(TALLOC_CTX *ctx, const char *user, const char *ngname);
-bool user_in_list(TALLOC_CTX *ctx, const char *user,const char **list);
+bool user_in_list(TALLOC_CTX *ctx, const char *user, const char * const *list);
 
 /* The following definitions come from auth/user_krb5.c  */
 struct PAC_LOGON_INFO;
diff --git a/source3/auth/user_util.c b/source3/auth/user_util.c
index 70ab5ad..ded2184 100644
--- a/source3/auth/user_util.c
+++ b/source3/auth/user_util.c
@@ -188,7 +188,7 @@ bool user_in_netgroup(TALLOC_CTX *ctx, const char *user, const char *ngname)
  and netgroup lists.
 ****************************************************************************/
 
-bool user_in_list(TALLOC_CTX *ctx, const char *user,const char **list)
+bool user_in_list(TALLOC_CTX *ctx, const char *user, const char * const *list)
 {
 	if (!list || !*list)
 		return False;
@@ -399,7 +399,7 @@ bool map_username(TALLOC_CTX *ctx, const char *user_in, char **p_user_out)
 		}
 
 		if (strchr_m(dosname,'*') ||
-		    user_in_list(ctx, user_in, (const char **)dosuserlist)) {
+		    user_in_list(ctx, user_in, (const char * const *)dosuserlist)) {
 			DEBUG(3,("Mapped user %s to %s\n",user_in,unixname));
 			mapped_user = True;
 
-- 
1.9.1


From ffd5015e225b7d160b094e0402b218fa8efa432b Mon Sep 17 00:00:00 2001
From: Stefan Metzmacher <metze at samba.org>
Date: Wed, 26 Feb 2014 20:16:26 +0100
Subject: [PATCH 19/64] s3:lib: fix const warnings in popt_common.c

Signed-off-by: Stefan Metzmacher <metze at samba.org>
---
 source3/lib/popt_common.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/source3/lib/popt_common.c b/source3/lib/popt_common.c
index df0465d..6f27bac 100644
--- a/source3/lib/popt_common.c
+++ b/source3/lib/popt_common.c
@@ -353,8 +353,11 @@ static void popt_common_credentials_callback(poptContext con,
 					const struct poptOption *opt,
 					const char *arg, const void *data)
 {
-	struct user_auth_info *auth_info = talloc_get_type_abort(
-		*((const char **)data), struct user_auth_info);
+	const void **pp = discard_const(data);
+	void *p = discard_const(*pp);
+	struct user_auth_info *auth_info =
+		talloc_get_type_abort(p,
+		struct user_auth_info);
 
 	if (reason == POPT_CALLBACK_REASON_PRE) {
 		set_cmdline_auth_info_username(auth_info, "GUEST");
@@ -501,7 +504,7 @@ void popt_burn_cmdline_password(int argc, char *argv[])
 struct poptOption popt_common_credentials[] = {
 	{ NULL, 0, POPT_ARG_CALLBACK|POPT_CBFLAG_PRE,
 	  (void *)popt_common_credentials_callback, 0,
-	  (const char *)&global_auth_info },
+	  (const void *)&global_auth_info },
 	{ "user", 'U', POPT_ARG_STRING, NULL, 'U', "Set the network username", "USERNAME" },
 	{ "no-pass", 'N', POPT_ARG_NONE, NULL, 'N', "Don't ask for a password" },
 	{ "kerberos", 'k', POPT_ARG_NONE, NULL, 'k', "Use kerberos (active directory) authentication" },
-- 
1.9.1


From 3c311f5babeb242da8938ae2db234e0504ca9093 Mon Sep 17 00:00:00 2001
From: Stefan Metzmacher <metze at samba.org>
Date: Wed, 26 Feb 2014 20:16:26 +0100
Subject: [PATCH 20/64] s3:lib/netapi/tests: fix invalid switch enum level
 warning

Signed-off-by: Stefan Metzmacher <metze at samba.org>
---
 source3/lib/netapi/tests/netgroup.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/source3/lib/netapi/tests/netgroup.c b/source3/lib/netapi/tests/netgroup.c
index c872087..dba4fe7 100644
--- a/source3/lib/netapi/tests/netgroup.c
+++ b/source3/lib/netapi/tests/netgroup.c
@@ -348,7 +348,7 @@ NET_API_STATUS netapitest_group(struct libnetapi_ctx *ctx,
 	printf("testing NetGroupSetInfo level 0\n");
 
 	status = NetGroupSetInfo(hostname, groupname, 0, (uint8_t *)&g0, &parm_err);
-	switch (status) {
+	switch ((int)status) {
 		case 0:
 			break;
 		case 50: /* not supported */
-- 
1.9.1


From 0142fa6618fdc3c06ad53215cae2477b6c28302d Mon Sep 17 00:00:00 2001
From: Stefan Metzmacher <metze at samba.org>
Date: Wed, 26 Feb 2014 20:16:26 +0100
Subject: [PATCH 21/64] s3:lib/netapi/examples: fix pointer from integer error
 in nltest.c

Signed-off-by: Stefan Metzmacher <metze at samba.org>
---
 source3/lib/netapi/examples/netlogon/nltest.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/source3/lib/netapi/examples/netlogon/nltest.c b/source3/lib/netapi/examples/netlogon/nltest.c
index f75a995..9f96bda 100644
--- a/source3/lib/netapi/examples/netlogon/nltest.c
+++ b/source3/lib/netapi/examples/netlogon/nltest.c
@@ -289,7 +289,7 @@ int main(int argc, const char **argv)
 			status = I_NetLogonControl2(opt_server,
 						    NETLOGON_CONTROL_SET_DBFLAG,
 						    query_level,
-						    (uint8_t *)opt_dbflag,
+						    (uint8_t *)&opt_dbflag,
 						    &buffer);
 			if (status != 0) {
 				fprintf(stderr, "I_NetlogonControl failed: Status = %d 0x%x %s\n",
-- 
1.9.1


From 52c7bc99d3d61eb689d93bf51f7c20a892e4dfd9 Mon Sep 17 00:00:00 2001
From: Stefan Metzmacher <metze at samba.org>
Date: Thu, 23 Oct 2014 10:17:40 +0200
Subject: [PATCH 22/64] s3:libsmb: remove unused variables in cliconnect.c

Signed-off-by: Stefan Metzmacher <metze at samba.org>
---
 source3/libsmb/cliconnect.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/source3/libsmb/cliconnect.c b/source3/libsmb/cliconnect.c
index 789a85d..2b1e2ec 100644
--- a/source3/libsmb/cliconnect.c
+++ b/source3/libsmb/cliconnect.c
@@ -1732,7 +1732,6 @@ static struct tevent_req *cli_session_setup_spnego_send(
 	char *OIDs[ASN1_MAX_OIDS];
 	int i;
 	const DATA_BLOB *server_blob;
-	NTSTATUS status;
 
 	req = tevent_req_create(mem_ctx, &state,
 				struct cli_session_setup_spnego_state);
@@ -3371,8 +3370,6 @@ static void cli_full_connection_done(struct tevent_req *subreq)
 {
 	struct tevent_req *req = tevent_req_callback_data(
 		subreq, struct tevent_req);
-	struct cli_full_connection_state *state = tevent_req_data(
-		req, struct cli_full_connection_state);
 	NTSTATUS status;
 
 	status = cli_tree_connect_recv(subreq);
-- 
1.9.1


From be09bc9807359f22fd734e3b0395c2908cc00281 Mon Sep 17 00:00:00 2001
From: Stefan Metzmacher <metze at samba.org>
Date: Wed, 26 Feb 2014 20:16:26 +0100
Subject: [PATCH 23/64] s3:libads: avoid some compiler warnings in ldap.c

We use helper variables and explicit casts using
discard_const_p() to avoid bogus const warnings.

Signed-off-by: Stefan Metzmacher <metze at samba.org>
---
 source3/libads/ldap.c | 36 +++++++++++++++++++++---------------
 1 file changed, 21 insertions(+), 15 deletions(-)

diff --git a/source3/libads/ldap.c b/source3/libads/ldap.c
index 06b4895..193d49f 100644
--- a/source3/libads/ldap.c
+++ b/source3/libads/ldap.c
@@ -1436,21 +1436,23 @@ static ADS_STATUS ads_modlist_add(TALLOC_CTX *ctx, ADS_MODLIST *mods,
 				  int mod_op, const char *name, 
 				  const void *_invals)
 {
-	const void **invals = (const void **)_invals;
 	int curmod;
 	LDAPMod **modlist = (LDAPMod **) *mods;
 	struct berval **ber_values = NULL;
 	char **char_values = NULL;
 
-	if (!invals) {
+	if (!_invals) {
 		mod_op = LDAP_MOD_DELETE;
 	} else {
-		if (mod_op & LDAP_MOD_BVALUES)
-			ber_values = ads_dup_values(ctx, 
-						(const struct berval **)invals);
-		else
-			char_values = ads_push_strvals(ctx, 
-						  (const char **) invals);
+		if (mod_op & LDAP_MOD_BVALUES) {
+			const struct berval **b;
+			b = discard_const_p(const struct berval *, _invals);
+			ber_values = ads_dup_values(ctx, b);
+		} else {
+			const char **c;
+			c = discard_const_p(const char *, _invals);
+			char_values = ads_push_strvals(ctx, c);
+		}
 	}
 
 	/* find the first empty slot */
@@ -2418,7 +2420,8 @@ static bool ads_dump_field(ADS_STRUCT *ads, char *field, void **values, void *da
 		     utf8_field=ldap_next_attribute(ads->ldap.ld,
 						    (LDAPMessage *)msg,b)) {
 			struct berval **ber_vals;
-			char **str_vals, **utf8_vals;
+			char **str_vals;
+			char **utf8_vals;
 			char *field;
 			bool string; 
 
@@ -2433,10 +2436,12 @@ static bool ads_dump_field(ADS_STRUCT *ads, char *field, void **values, void *da
 			string = fn(ads, field, NULL, data_area);
 
 			if (string) {
+				const char **p;
+
 				utf8_vals = ldap_get_values(ads->ldap.ld,
 					       	 (LDAPMessage *)msg, field);
-				str_vals = ads_pull_strvals(ctx, 
-						  (const char **) utf8_vals);
+				p = discard_const_p(const char *, utf8_vals);
+				str_vals = ads_pull_strvals(ctx, p);
 				fn(ads, field, (void **) str_vals, data_area);
 				ldap_value_free(utf8_vals);
 			} else {
@@ -3277,7 +3282,8 @@ ADS_STATUS ads_get_joinable_ous(ADS_STRUCT *ads,
 
 	for (msg = ads_first_entry(ads, res); msg;
 	     msg = ads_next_entry(ads, msg)) {
-
+		const char **p = discard_const_p(const char *, *ous);
+		int i = *num_ous;
 		char *dn = NULL;
 
 		dn = ads_get_dn(ads, talloc_tos(), msg);
@@ -3286,15 +3292,15 @@ ADS_STATUS ads_get_joinable_ous(ADS_STRUCT *ads,
 			return ADS_ERROR(LDAP_NO_MEMORY);
 		}
 
-		if (!add_string_to_array(mem_ctx, dn,
-					 (const char ***)ous,
-					 (int *)num_ous)) {
+		if (!add_string_to_array(mem_ctx, dn, &p, &i)) {
 			TALLOC_FREE(dn);
 			ads_msgfree(ads, res);
 			return ADS_ERROR(LDAP_NO_MEMORY);
 		}
 
 		TALLOC_FREE(dn);
+		*ous = discard_const_p(char *, p);
+		*num_ous = i;
 	}
 
 	ads_msgfree(ads, res);
-- 
1.9.1


From 259d4b1f819a4485043eb06c5f36512f18257d99 Mon Sep 17 00:00:00 2001
From: Stefan Metzmacher <metze at samba.org>
Date: Wed, 29 Oct 2014 12:21:07 +0100
Subject: [PATCH 24/64] s3:wscript_build: remove unused allow_warnings=True for
 'ads'

Signed-off-by: Stefan Metzmacher <metze at samba.org>
---
 source3/wscript_build | 1 -
 1 file changed, 1 deletion(-)

diff --git a/source3/wscript_build b/source3/wscript_build
index 54ba3a7..0c5b02b 100755
--- a/source3/wscript_build
+++ b/source3/wscript_build
@@ -454,7 +454,6 @@ bld.SAMBA3_LIBRARY('ads',
                    libads/ldap_schema.c
                    libads/util.c
                    libads/ndr.c''',
-                   allow_warnings=True,
                    deps='cli-ldap-common krb5samba ldap lber KRBCLIENT param LIBNMB libsmb DCUTIL smbldap',
                    private_library=True)
 
-- 
1.9.1


From 3e4a33c3e3cba4dbc4c87627b994442f051698b5 Mon Sep 17 00:00:00 2001
From: Stefan Metzmacher <metze at samba.org>
Date: Wed, 29 Oct 2014 12:04:36 +0100
Subject: [PATCH 25/64] s3:librpc/idl: mark struct smbXsrv_client as [public]

This avoids compiler warnings about unused code.

We don't use the NDR code for this yet, will be done
when we get multi-channel support.

Signed-off-by: Stefan Metzmacher <metze at samba.org>
---
 source3/librpc/idl/smbXsrv.idl | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/source3/librpc/idl/smbXsrv.idl b/source3/librpc/idl/smbXsrv.idl
index 0035442..ec6d0ea 100644
--- a/source3/librpc/idl/smbXsrv.idl
+++ b/source3/librpc/idl/smbXsrv.idl
@@ -79,7 +79,7 @@ interface smbXsrv
 
 	/* client */
 
-	typedef struct {
+	typedef [public] struct {
 		[ignore] struct tevent_context		*ev_ctx;
 		[ignore] struct messaging_context	*msg_ctx;
 
-- 
1.9.1


From 5d25e43d5299cea8ec7ff6b5968500091636724c Mon Sep 17 00:00:00 2001
From: Stefan Metzmacher <metze at samba.org>
Date: Wed, 29 Oct 2014 12:11:33 +0100
Subject: [PATCH 26/64] s3:modules: remove unused allow_warnings=True for
 non_posix_acls, vfs_shadow_copy2 and vfs_media_harmony

Signed-off-by: Stefan Metzmacher <metze at samba.org>
---
 source3/modules/wscript_build | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/source3/modules/wscript_build b/source3/modules/wscript_build
index e5d04f7..2dfb930 100644
--- a/source3/modules/wscript_build
+++ b/source3/modules/wscript_build
@@ -7,7 +7,6 @@ bld.SAMBA3_SUBSYSTEM('NFS4_ACLS',
 bld.SAMBA3_LIBRARY('non_posix_acls',
                    source='non_posix_acls.c',
                    deps='samba-util vfs',
-                   allow_warnings=True,
                    private_library=True)
 
 bld.SAMBA3_SUBSYSTEM('VFS_AIXACL_UTIL',
@@ -133,7 +132,6 @@ bld.SAMBA3_MODULE('vfs_shadow_copy',
 bld.SAMBA3_MODULE('vfs_shadow_copy2',
                  subsystem='vfs',
                  source='vfs_shadow_copy2.c',
-                 allow_warnings=True,
                  deps='samba-util tdb',
                  init_function='',
                  internal_module=bld.SAMBA3_IS_STATIC_MODULE('vfs_shadow_copy2'),
@@ -439,7 +437,6 @@ bld.SAMBA3_MODULE('vfs_time_audit',
 bld.SAMBA3_MODULE('vfs_media_harmony',
                  subsystem='vfs',
                  source='vfs_media_harmony.c',
-                 allow_warnings=True,
                  deps='samba-util',
                  init_function='',
                  internal_module=bld.SAMBA3_IS_STATIC_MODULE('vfs_media_harmony'),
-- 
1.9.1


From 783169bab9ee7efdbea8659bed73c07144ea1775 Mon Sep 17 00:00:00 2001
From: Stefan Metzmacher <metze at samba.org>
Date: Wed, 29 Oct 2014 12:12:48 +0100
Subject: [PATCH 27/64] s3:param: fix compiler warnings

---
 source3/param/loadparm.c | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c
index d6ba8fb..1a9ccf6 100644
--- a/source3/param/loadparm.c
+++ b/source3/param/loadparm.c
@@ -559,7 +559,7 @@ static void init_globals(struct loadparm_context *lp_ctx, bool reinit_globals)
 
 	init_printer_values(lp_ctx, Globals.ctx, &sDefault);
 
-	sDefault.ntvfs_handler = (const char **)str_list_make_v3(NULL, "unixuid default", NULL);
+	sDefault.ntvfs_handler = str_list_make_v3_const(NULL, "unixuid default", NULL);
 
 	DEBUG(3, ("Initialising global parameters\n"));
 
@@ -617,7 +617,7 @@ static void init_globals(struct loadparm_context *lp_ctx, bool reinit_globals)
 	string_set(Globals.ctx, &Globals.logon_home, "\\\\%N\\%U");
 	string_set(Globals.ctx, &Globals.logon_path, "\\\\%N\\%U\\profile");
 
-	Globals.name_resolve_order = (const char **)str_list_make_v3(NULL, "lmhosts wins host bcast", NULL);
+	Globals.name_resolve_order = str_list_make_v3_const(NULL, "lmhosts wins host bcast", NULL);
 	string_set(Globals.ctx, &Globals.password_server, "*");
 
 	Globals.algorithmic_rid_base = BASE_RID;
@@ -802,7 +802,7 @@ static void init_globals(struct loadparm_context *lp_ctx, bool reinit_globals)
 	Globals.winbind_trusted_domains_only = false;
 	Globals.winbind_nested_groups = true;
 	Globals.winbind_expand_groups = 0;
-	Globals.winbind_nss_info = (const char **)str_list_make_v3(NULL, "template", NULL);
+	Globals.winbind_nss_info = str_list_make_v3_const(NULL, "template", NULL);
 	Globals.winbind_refresh_tickets = false;
 	Globals.winbind_offline_logon = false;
 
@@ -820,7 +820,7 @@ static void init_globals(struct loadparm_context *lp_ctx, bool reinit_globals)
 	Globals.server_signing = SMB_SIGNING_DEFAULT;
 
 	Globals.defer_sharing_violations = true;
-	Globals.smb_ports = (const char **)str_list_make_v3(NULL, SMB_PORTS, NULL);
+	Globals.smb_ports = str_list_make_v3_const(NULL, SMB_PORTS, NULL);
 
 	Globals.enable_privileges = true;
 	Globals.host_msdfs        = true;
@@ -857,9 +857,9 @@ static void init_globals(struct loadparm_context *lp_ctx, bool reinit_globals)
 
 	string_set(Globals.ctx, &Globals.ncalrpc_dir, get_dyn_NCALRPCDIR());
 
-	Globals.server_services = (const char **)str_list_make_v3(NULL, "s3fs rpc nbt wrepl ldap cldap kdc drepl winbindd ntp_signd kcc dnsupdate dns", NULL);
+	Globals.server_services = str_list_make_v3_const(NULL, "s3fs rpc nbt wrepl ldap cldap kdc drepl winbindd ntp_signd kcc dnsupdate dns", NULL);
 
-	Globals.dcerpc_endpoint_servers = (const char **)str_list_make_v3(NULL, "epmapper wkssvc rpcecho samr netlogon lsarpc spoolss drsuapi dssetup unixinfo browser eventlog6 backupkey dnsserver", NULL);
+	Globals.dcerpc_endpoint_servers = str_list_make_v3_const(NULL, "epmapper wkssvc rpcecho samr netlogon lsarpc spoolss drsuapi dssetup unixinfo browser eventlog6 backupkey dnsserver", NULL);
 
 	Globals.tls_enabled = true;
 
@@ -881,26 +881,26 @@ static void init_globals(struct loadparm_context *lp_ctx, bool reinit_globals)
 	if (s == NULL) {
 		smb_panic("init_globals: ENOMEM");
 	}
-	Globals.samba_kcc_command = (const char **)str_list_make_v3(NULL, s, NULL);
+	Globals.samba_kcc_command = str_list_make_v3_const(NULL, s, NULL);
 	TALLOC_FREE(s);
 
 	s = talloc_asprintf(talloc_tos(), "%s/samba_dnsupdate", get_dyn_SCRIPTSBINDIR());
 	if (s == NULL) {
 		smb_panic("init_globals: ENOMEM");
 	}
-	Globals.dns_update_command = (const char **)str_list_make_v3(NULL, s, NULL);
+	Globals.dns_update_command = str_list_make_v3_const(NULL, s, NULL);
 	TALLOC_FREE(s);
 
 	s = talloc_asprintf(talloc_tos(), "%s/samba_spnupdate", get_dyn_SCRIPTSBINDIR());
 	if (s == NULL) {
 		smb_panic("init_globals: ENOMEM");
 	}
-	Globals.spn_update_command = (const char **)str_list_make_v3(NULL, s, NULL);
+	Globals.spn_update_command = str_list_make_v3_const(NULL, s, NULL);
 	TALLOC_FREE(s);
 
-	Globals.nsupdate_command = (const char **)str_list_make_v3(NULL, "/usr/bin/nsupdate -g", NULL);
+	Globals.nsupdate_command = str_list_make_v3_const(NULL, "/usr/bin/nsupdate -g", NULL);
 
-	Globals.rndc_command = (const char **)str_list_make_v3(NULL, "/usr/sbin/rndc", NULL);
+	Globals.rndc_command = str_list_make_v3_const(NULL, "/usr/sbin/rndc", NULL);
 
 	Globals.cldap_port = 389;
 
@@ -1163,7 +1163,7 @@ const char **lp_parm_string_list(int snum, const char *type, const char *option,
 		data->list = str_list_make_v3(NULL, data->value, NULL);
 	}
 
-	return (const char **)data->list;
+	return discard_const_p(const char *, data->list);
 }
 
 /* Return parametric option from a given service. Type is a part of option before ':' */
-- 
1.9.1


From 73518f4337ddfb8841a8f36aab1eac2b4128bdb3 Mon Sep 17 00:00:00 2001
From: Stefan Metzmacher <metze at samba.org>
Date: Wed, 29 Oct 2014 12:13:23 +0100
Subject: [PATCH 28/64] s3:wscript_build: remove unused allow_warnings=True for
 'param'

Signed-off-by: Stefan Metzmacher <metze at samba.org>
---
 source3/wscript_build | 1 -
 1 file changed, 1 deletion(-)

diff --git a/source3/wscript_build b/source3/wscript_build
index 0c5b02b..6373913 100755
--- a/source3/wscript_build
+++ b/source3/wscript_build
@@ -190,7 +190,6 @@ bld.SAMBA3_SUBSYSTEM('param',
                    lib/sharesec.c
                    lib/ldap_debug_handler.c
                    lib/util_names.c''',
-                   allow_warnings=True,
                    deps='samba-util PARAM_UTIL ldap lber LOADPARM_CTX samba3core smbconf param_local.h param_global.h cups''')
 
 # this includes only the low level parse code, not stuff
-- 
1.9.1


From 4b882e94185cca6a3587c8c2f326084dc190fd45 Mon Sep 17 00:00:00 2001
From: Stefan Metzmacher <metze at samba.org>
Date: Wed, 26 Feb 2014 20:16:26 +0100
Subject: [PATCH 29/64] s3:passdb: always copy the history in
 pdb_set_plaintext_passwd()

We should not write to memory marked as const
(returned from pdb_get_pw_history())!

Signed-off-by: Stefan Metzmacher <metze at samba.org>
---
 source3/passdb/pdb_get_set.c | 33 ++++++++++++++-------------------
 1 file changed, 14 insertions(+), 19 deletions(-)

diff --git a/source3/passdb/pdb_get_set.c b/source3/passdb/pdb_get_set.c
index 0d7f4cb..1b716f4 100644
--- a/source3/passdb/pdb_get_set.c
+++ b/source3/passdb/pdb_get_set.c
@@ -1001,6 +1001,7 @@ bool pdb_set_plaintext_passwd(struct samu *sampass, const char *plaintext)
 	uchar *pwhistory;
 	uint32_t pwHistLen;
 	uint32_t current_history_len;
+	const uint8_t *current_history;
 
 	if (!plaintext)
 		return False;
@@ -1051,33 +1052,27 @@ bool pdb_set_plaintext_passwd(struct samu *sampass, const char *plaintext)
 	 * the pw_history was first loaded into the struct samu struct
 	 * and now.... JRA.
 	 */
-	pwhistory = (uchar *)pdb_get_pw_history(sampass, &current_history_len);
-
-	if ((current_history_len != 0) && (pwhistory == NULL)) {
+	current_history = pdb_get_pw_history(sampass, &current_history_len);
+	if ((current_history_len != 0) && (current_history == NULL)) {
 		DEBUG(1, ("pdb_set_plaintext_passwd: pwhistory == NULL!\n"));
 		return false;
 	}
 
-	if (current_history_len < pwHistLen) {
-		/*
-		 * Ensure we have space for the needed history. This
-		 * also takes care of an account which did not have
-		 * any history at all so far, i.e. pwhistory==NULL
-		 */
-		uchar *new_history = talloc_zero_array(
+	/*
+	 * Ensure we have space for the needed history. This
+	 * also takes care of an account which did not have
+	 * any history at all so far, i.e. pwhistory==NULL
+	 */
+	pwhistory = talloc_zero_array(
 			sampass, uchar,
 			pwHistLen*PW_HISTORY_ENTRY_LEN);
-
-		if (!new_history) {
-			return False;
-		}
-
-		memcpy(new_history, pwhistory,
-		       current_history_len*PW_HISTORY_ENTRY_LEN);
-
-		pwhistory = new_history;
+	if (!pwhistory) {
+		return false;
 	}
 
+	memcpy(pwhistory, current_history,
+	       current_history_len*PW_HISTORY_ENTRY_LEN);
+
 	/*
 	 * Make room for the new password in the history list.
 	 */
-- 
1.9.1


From 83adc4d51a6a0ff7ca0ee6866d6f5cb77353207d Mon Sep 17 00:00:00 2001
From: Stefan Metzmacher <metze at samba.org>
Date: Wed, 26 Feb 2014 20:16:26 +0100
Subject: [PATCH 30/64] s3:passdb: avoid invalid pointer type warnings in
 pdb_wbc_sam.c

Signed-off-by: Stefan Metzmacher <metze at samba.org>
---
 source3/passdb/pdb_wbc_sam.c | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/source3/passdb/pdb_wbc_sam.c b/source3/passdb/pdb_wbc_sam.c
index 655890f..2343649 100644
--- a/source3/passdb/pdb_wbc_sam.c
+++ b/source3/passdb/pdb_wbc_sam.c
@@ -135,18 +135,21 @@ static NTSTATUS pdb_wbc_sam_lookup_rids(struct pdb_methods *methods,
 					enum lsa_SidType *attrs)
 {
 	NTSTATUS result = NT_STATUS_OK;
+	const char *p = NULL;
+	const char **pp = NULL;
 	char *domain = NULL;
 	char **account_names = NULL;
 	enum lsa_SidType *attr_list = NULL;
 	int i;
 
 	if (!winbind_lookup_rids(talloc_tos(), domain_sid, num_rids, rids,
-				 (const char **)&domain,
-				 (const char ***)&account_names, &attr_list))
+				 &p, &pp, &attr_list))
 	{
 		result = NT_STATUS_NONE_MAPPED;
 		goto done;
 	}
+	domain = discard_const_p(char, p);
+	account_names = discard_const_p(char *, pp);
 
 	memcpy(attrs, attr_list, num_rids * sizeof(enum lsa_SidType));
 
@@ -243,16 +246,18 @@ static NTSTATUS pdb_wbc_sam_getgrsid(struct pdb_methods *methods, GROUP_MAP *map
 				 struct dom_sid sid)
 {
 	NTSTATUS result = NT_STATUS_OK;
+	const char *p1 = NULL, *p2 = NULL;
 	char *name = NULL;
 	char *domain = NULL;
 	enum lsa_SidType name_type;
 	gid_t gid;
 
-	if (!winbind_lookup_sid(talloc_tos(), &sid, (const char **)&domain,
-				(const char **) &name, &name_type)) {
+	if (!winbind_lookup_sid(talloc_tos(), &sid, &p1, &p2, &name_type)) {
 		result = NT_STATUS_NO_SUCH_GROUP;
 		goto done;
 	}
+	domain = discard_const_p(char, p1);
+	name = discard_const_p(char, p2);
 
 	if ((name_type != SID_NAME_DOM_GRP) &&
 	    (name_type != SID_NAME_DOMAIN) &&
@@ -282,6 +287,7 @@ static NTSTATUS pdb_wbc_sam_getgrgid(struct pdb_methods *methods, GROUP_MAP *map
 				 gid_t gid)
 {
 	NTSTATUS result = NT_STATUS_OK;
+	const char *p1 = NULL, *p2 = NULL;
 	char *name = NULL;
 	char *domain = NULL;
 	struct dom_sid sid;
@@ -292,11 +298,12 @@ static NTSTATUS pdb_wbc_sam_getgrgid(struct pdb_methods *methods, GROUP_MAP *map
 		goto done;
 	}
 
-	if (!winbind_lookup_sid(talloc_tos(), &sid, (const char **)&domain,
-				(const char **)&name, &name_type)) {
+	if (!winbind_lookup_sid(talloc_tos(), &sid, &p1, &p2, &name_type)) {
 		result = NT_STATUS_NO_SUCH_GROUP;
 		goto done;
 	}
+	domain = discard_const_p(char, p1);
+	name = discard_const_p(char, p2);
 
 	if ((name_type != SID_NAME_DOM_GRP) &&
 	    (name_type != SID_NAME_DOMAIN) &&
-- 
1.9.1


From f789e57e360805871856b793b5a5878e51cb3517 Mon Sep 17 00:00:00 2001
From: Kai Blin <kai at samba.org>
Date: Fri, 14 Mar 2014 09:07:16 +0100
Subject: [PATCH 31/64] s3:printing: Avoid compiler warning about unused label

Signed-off-by: Kai Blin <kai at samba.org>
Reviewed-by: Stefan Metzmacher <metze at samba.org>
---
 source3/printing/pcap.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/source3/printing/pcap.c b/source3/printing/pcap.c
index c5524ad..7261118 100644
--- a/source3/printing/pcap.c
+++ b/source3/printing/pcap.c
@@ -181,7 +181,11 @@ void pcap_cache_reload(struct tevent_context *ev,
 
 	pcap_reloaded = std_pcap_cache_reload(pcap_name, &pcache);
 
+/* Fix silly compiler warning about done not being used if none of the above
+ * ifdefs are used */
+#if defined(HAVE_CUPS) || defined(HAVE_IPRINT) || defined(SYSV) || defined(HPUX) || defined(AIX)
 done:
+#endif
 	DEBUG(3, ("reload status: %s\n", (pcap_reloaded) ? "ok" : "error"));
 
 	if ((pcap_reloaded) && (post_cache_fill_fn_handled == false)) {
-- 
1.9.1


From 85f7d9a4ae4dd576bd655def319d9e0913726322 Mon Sep 17 00:00:00 2001
From: Stefan Metzmacher <metze at samba.org>
Date: Thu, 3 Jul 2014 13:14:20 +0200
Subject: [PATCH 32/64] s3:printing: fix some const warnings in print_iprint.c

Signed-off-by: Stefan Metzmacher <metze at samba.org>
---
 source3/printing/print_iprint.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/source3/printing/print_iprint.c b/source3/printing/print_iprint.c
index eeb193c..1c9e5a2 100644
--- a/source3/printing/print_iprint.c
+++ b/source3/printing/print_iprint.c
@@ -206,19 +206,19 @@ static int iprint_get_server_version(http_t *http, char* serviceUri)
 
 static int iprint_cache_add_printer(http_t *http,
 				   int reqId,
-				   char *url,
+				   const char *url,
 				   struct pcap_cache **pcache)
 {
 	ipp_t		*request = NULL,	/* IPP Request */
 			*response = NULL;	/* IPP Response */
 	ipp_attribute_t	*attr;			/* Current attribute */
 	cups_lang_t	*language = NULL;	/* Default language */
-	char		*name,			/* printer-name attribute */
-			*info,			/* printer-info attribute */
-			smb_enabled,		/* smb-enabled attribute */
+	const char	*name,			/* printer-name attribute */
+			*info;			/* printer-info attribute */
+	char		smb_enabled,		/* smb-enabled attribute */
 			secure;			/* security-enabled attrib. */
 
-	char		*httpPath;	/* path portion of the printer-uri */
+	const char	*httpPath;	/* path portion of the printer-uri */
 
 	static const char *pattrs[] =	/* Requested printer attributes */
 			{
@@ -440,7 +440,7 @@ bool iprint_cache_reload(struct pcap_cache **_pcache)
 			{
 				for (i = 0; i<ippGetCount(attr); i++)
 				{
-					char *url = ippGetString(attr, i, NULL);
+					const char *url = ippGetString(attr, i, NULL);
 					if (!url || !strlen(url))
 						continue;
 					iprint_cache_add_printer(http, i+2, url,
-- 
1.9.1


From 8d7ebb0d407f88ea1dcb5cd99e8bd0f563c2832b Mon Sep 17 00:00:00 2001
From: Stefan Metzmacher <metze at samba.org>
Date: Wed, 26 Feb 2014 20:16:26 +0100
Subject: [PATCH 33/64] s3:registry: use discard_const_p() to avoid const
 warning in smb_iconv() define

I'm wondering why we have this in reg_parse_internal.h at all!

But for now just fix warnings...

Signed-off-by: Stefan Metzmacher <metze at samba.org>
---
 source3/registry/reg_parse_internal.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/source3/registry/reg_parse_internal.h b/source3/registry/reg_parse_internal.h
index bd364a5..1440d55 100644
--- a/source3/registry/reg_parse_internal.h
+++ b/source3/registry/reg_parse_internal.h
@@ -38,7 +38,7 @@ struct cbuf;
 #if defined USE_NATIVE_ICONV && defined HAVE_NATIVE_ICONV
 #  define smb_iconv_t     iconv_t
 #  define smb_iconv(CD, IPTR, ILEN, OPTR, OLEN) \
-	iconv(CD, (char**)(IPTR), ILEN, OPTR, OLEN)
+	iconv(CD, discard_const_p(char*, (IPTR)), ILEN, OPTR, OLEN)
 #  define smb_iconv_open  iconv_open
 #  define smb_iconv_close iconv_close
 #endif
-- 
1.9.1


From effcc448adea0f9e69dc107018b0c02fbb59bd44 Mon Sep 17 00:00:00 2001
From: Stefan Metzmacher <metze at samba.org>
Date: Wed, 29 Oct 2014 12:18:14 +0100
Subject: [PATCH 34/64] s3:wscript_build: remove unused allow_warnings=True for
 'smbregistry'

Signed-off-by: Stefan Metzmacher <metze at samba.org>
---
 source3/wscript_build | 1 -
 1 file changed, 1 deletion(-)

diff --git a/source3/wscript_build b/source3/wscript_build
index 6373913..d6edc68 100755
--- a/source3/wscript_build
+++ b/source3/wscript_build
@@ -221,7 +221,6 @@ bld.SAMBA3_LIBRARY('smbregistry',
                    replace util_reg samba-util samba-security
                    errors3 dbwrap samba3-util''',
                    allow_undefined_symbols=True,
-                   allow_warnings=True,
                    private_library=True)
 
 bld.SAMBA3_SUBSYSTEM('REG_SMBCONF',
-- 
1.9.1


From e352177dc5d16bb5816e4ec5753515ad2b20d5f4 Mon Sep 17 00:00:00 2001
From: Stefan Metzmacher <metze at samba.org>
Date: Wed, 26 Feb 2014 20:16:26 +0100
Subject: [PATCH 35/64] s3:smbd: do casting of dm_sessid_t in steps

This makes it more explicit and avoids compiler warnings.

Signed-off-by: Stefan Metzmacher <metze at samba.org>
---
 source3/smbd/dmapi.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/source3/smbd/dmapi.c b/source3/smbd/dmapi.c
index 8c93873..90c24bd 100644
--- a/source3/smbd/dmapi.c
+++ b/source3/smbd/dmapi.c
@@ -266,18 +266,20 @@ uint32 dmapi_file_flags(const char * const path)
 	uint		nevents;
 
 	dm_sessid_t     dmapi_session;
-	const void      *dmapi_session_ptr;
+	dm_sessid_t     *dmapi_session_ptr;
+	const void      *_dmapi_session_ptr;
 	void	        *dm_handle = NULL;
 	size_t	        dm_handle_len = 0;
 
 	uint32	        flags = 0;
 
-	dmapi_session_ptr = dmapi_get_current_session();
-	if (dmapi_session_ptr == NULL) {
+	_dmapi_session_ptr = dmapi_get_current_session();
+	if (_dmapi_session_ptr == NULL) {
 		return 0;
 	}
 
-	dmapi_session = *(const dm_sessid_t *)dmapi_session_ptr;
+	dmapi_session_ptr = discard_const_p(dm_sessid_t, _dmapi_session_ptr);
+	dmapi_session = *dmapi_session_ptr;
 	if (dmapi_session == DM_NO_SESSION) {
 		return 0;
 	}
-- 
1.9.1


From 43ef8007ae80ac88c2df651caa61262727f92ef9 Mon Sep 17 00:00:00 2001
From: Stefan Metzmacher <metze at samba.org>
Date: Wed, 26 Feb 2014 20:16:26 +0100
Subject: [PATCH 36/64] s3:smbd: avoid a compiler warning in
 open_sockets_smbd()

Signed-off-by: Stefan Metzmacher <metze at samba.org>
---
 source3/smbd/server.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/source3/smbd/server.c b/source3/smbd/server.c
index 0d649e1..fc1622a 100644
--- a/source3/smbd/server.c
+++ b/source3/smbd/server.c
@@ -755,7 +755,9 @@ static bool open_sockets_smbd(struct smbd_parent_context *parent,
 
 	/* use a reasonable default set of ports - listing on 445 and 139 */
 	if (smb_ports) {
-		ports = (const char **)str_list_make_v3(talloc_tos(), smb_ports, NULL);
+		char **l;
+		l = str_list_make_v3(talloc_tos(), smb_ports, NULL);
+		ports = discard_const_p(const char *, l);
 	}
 
 	for (j = 0; ports && ports[j]; j++) {
-- 
1.9.1


From 23e7704a1d0859cfee1816ab098dcf5786797362 Mon Sep 17 00:00:00 2001
From: Stefan Metzmacher <metze at samba.org>
Date: Thu, 23 Oct 2014 10:18:21 +0200
Subject: [PATCH 37/64] s3:torture: avoid nesting of macros and function calls
 in torture_cli_session_setup2()

Signed-off-by: Stefan Metzmacher <metze at samba.org>
---
 source3/torture/torture.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/source3/torture/torture.c b/source3/torture/torture.c
index 2cd63e1..f90f882 100644
--- a/source3/torture/torture.c
+++ b/source3/torture/torture.c
@@ -416,10 +416,11 @@ bool torture_cli_session_setup2(struct cli_state *cli, uint16 *new_vuid)
 	bool ret;
 
 	cli_state_set_uid(cli, 0);
-	ret = NT_STATUS_IS_OK(cli_session_setup(cli, username,
-						password, passlen,
-						password, passlen,
-						workgroup));
+	status = cli_session_setup(cli, username,
+				   password, passlen,
+				   password, passlen,
+				   workgroup);
+	ret = NT_STATUS_IS_OK(status);
 	*new_vuid = cli_state_get_uid(cli);
 	cli_state_set_uid(cli, old_vuid);
 	return ret;
-- 
1.9.1


From eccf481339ac1ea0ca0ca7e750c96d1afe527570 Mon Sep 17 00:00:00 2001
From: Stefan Metzmacher <metze at samba.org>
Date: Wed, 26 Feb 2014 20:16:26 +0100
Subject: [PATCH 38/64] s3:utils: add debug functions instead of magic format
 strings in net_idmap_check.c

This way the compiler can check the format string and doesn't generate warnings.

Signed-off-by: Stefan Metzmacher <metze at samba.org>
---
 source3/utils/net_idmap_check.c | 47 ++++++++++++++++++++++++++++++++++-------
 1 file changed, 39 insertions(+), 8 deletions(-)

diff --git a/source3/utils/net_idmap_check.c b/source3/utils/net_idmap_check.c
index 4b82871..51f4a40 100644
--- a/source3/utils/net_idmap_check.c
+++ b/source3/utils/net_idmap_check.c
@@ -73,7 +73,9 @@ static bool is_map(const struct record* r) {
 /* action *********************************************************************/
 
 typedef struct check_action {
-	const char* fmt;
+	void (*fmt)(struct check_action *a,
+		    struct record *r,
+		    TDB_DATA *v);
 	const char* name;
 	const char* prompt;
 	const char* answers;
@@ -97,6 +99,38 @@ struct check_actions {
 	check_action invalid_diff;
 };
 
+static void invalid_mapping_fmt(struct check_action *a,
+				struct record *r,
+				TDB_DATA *v)
+{
+	d_printf("%1$s: %2$s -> %3$s\n(%4$s <- %3$s)\n",
+		 a->name,
+		 print_data(r, r->key),
+		 print_data(r, r->val),
+		 (v ? print_data(r, *v) : ""));
+}
+
+static void record_exists_fmt(struct check_action *a,
+			      struct record *r,
+			      TDB_DATA *v)
+{
+	d_printf("%1$s: %2$s\n-%4$s\n+%3$s\n",
+		 a->name,
+		 print_data(r, r->key),
+		 print_data(r, r->val),
+		 (v ? print_data(r, *v) : ""));
+}
+
+static void valid_mapping_fmt(struct check_action *a,
+			      struct record *r,
+			      TDB_DATA *v)
+{
+	d_printf("%1$s: %2$s <-> %3$s\n",
+		 a->name,
+		 print_data(r, r->key),
+		 print_data(r, r->val));
+}
+
 static struct check_actions
 check_actions_init(const struct check_options* opts) {
 	struct check_actions ret = {
@@ -117,7 +151,7 @@ check_actions_init(const struct check_options* opts) {
 			.verbose = true,
 		},
 		.invalid_mapping = (check_action) {
-			.fmt = "%1$s: %2$s -> %3$s\n(%4$s <- %3$s)\n",
+			.fmt = invalid_mapping_fmt,
 			.name = "Invalid mapping",
 			.prompt = "[e]dit/[d]elete/[D]elete all"
 			"/[s]kip/[S]kip all",
@@ -134,7 +168,7 @@ check_actions_init(const struct check_options* opts) {
 			.verbose = true,
 		},
 		.record_exists = (check_action) {
-			.fmt = "%1$s: %2$s\n-%4$s\n+%3$s\n",
+			.fmt = record_exists_fmt,
 			.name = "Record exists",
 			.prompt = "[o]verwrite/[O]verwrite all/[e]dit"
 			"/[d]elete/[D]elete all/[s]kip/[S]kip all",
@@ -164,7 +198,7 @@ check_actions_init(const struct check_options* opts) {
 			.verbose = true,
 		},
 		.valid_mapping = (check_action) {
-			.fmt = "%1$s: %2$s <-> %3$s\n",
+			.fmt = valid_mapping_fmt,
 			.name = "Mapping",
 			.auto_action = 's',
 			.verbose = opts->verbose,
@@ -230,10 +264,7 @@ static char get_action(struct check_action* a, struct record* r, TDB_DATA* v) {
 				d_printf("\n");
 			}
 		} else {
-			d_printf(a->fmt, a->name,
-				 print_data(r, r->key),
-				 print_data(r, r->val),
-				 (v ? print_data(r, *v) : ""));
+			a->fmt(a, r, v);
 		}
 	}
 
-- 
1.9.1


From a5993e901df4820aa65371ec29ae95283ea05f2c Mon Sep 17 00:00:00 2001
From: Stefan Metzmacher <metze at samba.org>
Date: Wed, 29 Oct 2014 11:39:01 +0100
Subject: [PATCH 39/64] s3:utils: fix compiler warnings in status_profile*.c

Signed-off-by: Stefan Metzmacher <metze at samba.org>
---
 source3/utils/status_profile.c       | 2 +-
 source3/utils/status_profile_dummy.c | 3 +++
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/source3/utils/status_profile.c b/source3/utils/status_profile.c
index 282dea3..f98feac 100644
--- a/source3/utils/status_profile.c
+++ b/source3/utils/status_profile.c
@@ -42,7 +42,7 @@ static void profile_separator(const char * title)
 /*******************************************************************
  dump the elements of the profile structure
   ******************************************************************/
-bool status_profile_dump(bool verbose)
+bool status_profile_dump(bool be_verbose)
 {
 	if (!profile_setup(NULL, True)) {
 		fprintf(stderr,"Failed to initialise profile memory\n");
diff --git a/source3/utils/status_profile_dummy.c b/source3/utils/status_profile_dummy.c
index c58f696..36a1770 100644
--- a/source3/utils/status_profile_dummy.c
+++ b/source3/utils/status_profile_dummy.c
@@ -20,6 +20,9 @@
 #include "includes.h"
 #include "smbprofile.h"
 
+bool status_profile_dump(bool be_verbose);
+bool status_profile_rates(bool be_verbose);
+
 bool status_profile_dump(bool be_verbose)
 {
 	fprintf(stderr, "Profile data unavailable\n");
-- 
1.9.1


From 5129b32d91dfcb50639163e76308427fab487856 Mon Sep 17 00:00:00 2001
From: Stefan Metzmacher <metze at samba.org>
Date: Wed, 26 Feb 2014 20:16:26 +0100
Subject: [PATCH 40/64] s3:winbindd: avoid invalid pointer type warnings

Signed-off-by: Stefan Metzmacher <metze at samba.org>
---
 source3/winbindd/idmap_nss.c      | 4 +++-
 source3/winbindd/winbindd_msrpc.c | 5 ++++-
 source3/winbindd/winbindd_rpc.c   | 5 ++++-
 3 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/source3/winbindd/idmap_nss.c b/source3/winbindd/idmap_nss.c
index 5cd2bc2..e65a499 100644
--- a/source3/winbindd/idmap_nss.c
+++ b/source3/winbindd/idmap_nss.c
@@ -135,6 +135,7 @@ static NTSTATUS idmap_nss_sids_to_unixids(struct idmap_domain *dom, struct id_ma
 	for (i = 0; ids[i]; i++) {
 		struct group *gr;
 		enum lsa_SidType type;
+		const char *p = NULL;
 		char *name = NULL;
 		bool ret;
 
@@ -142,8 +143,9 @@ static NTSTATUS idmap_nss_sids_to_unixids(struct idmap_domain *dom, struct id_ma
 		   the following call will not recurse so this is safe */
 		(void)winbind_on();
 		ret = winbind_lookup_sid(talloc_tos(), ids[i]->sid, NULL,
-					 (const char **)&name, &type);
+					 &p, &type);
 		(void)winbind_off();
+		name = discard_const_p(char, p);
 
 		if (!ret) {
 			/* TODO: how do we know if the name is really not mapped,
diff --git a/source3/winbindd/winbindd_msrpc.c b/source3/winbindd/winbindd_msrpc.c
index 8454f93..77e5ffc 100644
--- a/source3/winbindd/winbindd_msrpc.c
+++ b/source3/winbindd/winbindd_msrpc.c
@@ -234,6 +234,7 @@ static NTSTATUS msrpc_name_to_sid(struct winbindd_domain *domain,
 	struct dom_sid *sids = NULL;
 	enum lsa_SidType *types = NULL;
 	char *full_name = NULL;
+	const char *names[1];
 	NTSTATUS name_map_status = NT_STATUS_UNSUCCESSFUL;
 	char *mapped_name = NULL;
 
@@ -265,8 +266,10 @@ static NTSTATUS msrpc_name_to_sid(struct winbindd_domain *domain,
 	DEBUG(3,("name_to_sid [rpc] %s for domain %s\n",
 		 full_name?full_name:"", domain_name ));
 
+	names[0] = full_name;
+
 	result = winbindd_lookup_names(mem_ctx, domain, 1,
-				       (const char **)&full_name, NULL,
+				       names, NULL,
 				       &sids, &types);
 	if (!NT_STATUS_IS_OK(result))
 		return result;
diff --git a/source3/winbindd/winbindd_rpc.c b/source3/winbindd/winbindd_rpc.c
index 7a80237..03bc9b5 100644
--- a/source3/winbindd/winbindd_rpc.c
+++ b/source3/winbindd/winbindd_rpc.c
@@ -277,6 +277,7 @@ NTSTATUS rpc_name_to_sid(TALLOC_CTX *mem_ctx,
 	enum lsa_SidType *types = NULL;
 	struct dom_sid *sids = NULL;
 	char *full_name = NULL;
+	const char *names[1];
 	char *mapped_name = NULL;
 	NTSTATUS status;
 
@@ -302,6 +303,8 @@ NTSTATUS rpc_name_to_sid(TALLOC_CTX *mem_ctx,
 	DEBUG(3,("name_to_sid: %s for domain %s\n",
 		 full_name ? full_name : "", domain_name ));
 
+	names[0] = full_name;
+
 	/*
 	 * We don't run into deadlocks here, cause winbind_off() is
 	 * called in the main function.
@@ -310,7 +313,7 @@ NTSTATUS rpc_name_to_sid(TALLOC_CTX *mem_ctx,
 					 mem_ctx,
 					 lsa_policy,
 					 1, /* num_names */
-					 (const char **) &full_name,
+					 names,
 					 NULL, /* domains */
 					 1, /* level */
 					 &sids,
-- 
1.9.1


From ae39ece18f2bb4ea516a46fc1b97107a616f4ab5 Mon Sep 17 00:00:00 2001
From: Stefan Metzmacher <metze at samba.org>
Date: Wed, 26 Feb 2014 20:16:26 +0100
Subject: [PATCH 41/64] s3:winbindd: make use of talloc_string_sub2() in
 generate_krb5_ccache()

This way we don't pass a given format string to talloc_asprintf().

Signed-off-by: Stefan Metzmacher <metze at samba.org>
---
 source3/winbindd/winbindd_pam.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/source3/winbindd/winbindd_pam.c b/source3/winbindd/winbindd_pam.c
index 5351937..d56d2fa 100644
--- a/source3/winbindd/winbindd_pam.c
+++ b/source3/winbindd/winbindd_pam.c
@@ -512,7 +512,20 @@ static const char *generate_krb5_ccache(TALLOC_CTX *mem_ctx,
 				p++;
 
 				if (p != NULL && *p == 'u' && strchr(p, '%') == NULL) {
-					gen_cc = talloc_asprintf(mem_ctx, type, uid);
+					char uid_str[sizeof("18446744073709551615")];
+
+					snprintf(uid_str, sizeof(uid_str), "%u", uid);
+
+					gen_cc = talloc_string_sub2(mem_ctx,
+							type,
+							"%u",
+							uid_str,
+							/* remove_unsafe_characters */
+							false,
+							/* replace_once */
+							true,
+							/* allow_trailing_dollar */
+							false);
 				}
 			}
 		}
-- 
1.9.1


From 06078e880fe79346253cae0c551bf05a6c154cb3 Mon Sep 17 00:00:00 2001
From: Stefan Metzmacher <metze at samba.org>
Date: Wed, 29 Oct 2014 12:21:07 +0100
Subject: [PATCH 42/64] s3:wscript_build: remove unused allow_warnings=True for
 'KRBCLIENT'

Signed-off-by: Stefan Metzmacher <metze at samba.org>
---
 source3/wscript_build | 1 -
 1 file changed, 1 deletion(-)

diff --git a/source3/wscript_build b/source3/wscript_build
index d6edc68..d5d1247 100755
--- a/source3/wscript_build
+++ b/source3/wscript_build
@@ -255,7 +255,6 @@ bld.SAMBA3_LIBRARY('util_cmdline',
 
 bld.SAMBA3_SUBSYSTEM('KRBCLIENT',
                      source='libads/kerberos.c libads/ads_status.c',
-                     allow_warnings=True,
                      public_deps='krb5samba k5crypto gssapi LIBTSOCKET CLDAP LIBNMB')
 
 bld.SAMBA3_SUBSYSTEM('samba3util',
-- 
1.9.1


From ad83e898c9638df4c69e9c848e9feeaefe63447b Mon Sep 17 00:00:00 2001
From: Stefan Metzmacher <metze at samba.org>
Date: Thu, 27 Feb 2014 09:49:47 +0100
Subject: [PATCH 43/64] s4:lib/registry: avoid some const warnings

Signed-off-by: Stefan Metzmacher <metze at samba.org>
---
 source4/lib/registry/tools/regpatch.c |  4 ++--
 source4/lib/registry/tools/regshell.c | 42 +++++++++++++++++------------------
 source4/lib/registry/tools/regtree.c  |  4 ++--
 3 files changed, 25 insertions(+), 25 deletions(-)

diff --git a/source4/lib/registry/tools/regpatch.c b/source4/lib/registry/tools/regpatch.c
index a8c1843..34cbd1c 100644
--- a/source4/lib/registry/tools/regpatch.c
+++ b/source4/lib/registry/tools/regpatch.c
@@ -26,7 +26,7 @@
 #include "param/param.h"
 #include "events/events.h"
 
-int main(int argc, char **argv)
+int main(int argc, const char **argv)
 {
   	int opt;
 	poptContext pc;
@@ -44,7 +44,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) {
 	}
diff --git a/source4/lib/registry/tools/regshell.c b/source4/lib/registry/tools/regshell.c
index dd154f7..448f957 100644
--- a/source4/lib/registry/tools/regshell.c
+++ b/source4/lib/registry/tools/regshell.c
@@ -37,9 +37,9 @@ struct regshell_context {
 	struct registry_key *root;
 };
 
-static WERROR get_full_path(struct regshell_context *ctx, char *path, char **ret_path) 
+static WERROR get_full_path(struct regshell_context *ctx, const char *path, char **ret_path)
 {
-	char *dir;
+	const char *dir;
 	char *tmp;
 	char *new_path;
 
@@ -49,7 +49,7 @@ static WERROR get_full_path(struct regshell_context *ctx, char *path, char **ret
  		new_path = talloc_strdup(ctx, ctx->path);
 	}		
 
-	dir = strtok(path, "\\");
+	dir = strtok(discard_const_p(char, path), "\\");
 	if (dir == NULL) {
 		*ret_path = new_path;
 		return WERR_OK;
@@ -98,7 +98,7 @@ static WERROR get_full_path(struct regshell_context *ctx, char *path, char **ret
  * exit
  */
 
-static WERROR cmd_info(struct regshell_context *ctx, int argc, char **argv)
+static WERROR cmd_info(struct regshell_context *ctx, int argc, const char **argv)
 {
 	struct security_descriptor *sec_desc = NULL;
 	time_t last_mod;
@@ -150,7 +150,7 @@ static WERROR cmd_info(struct regshell_context *ctx, int argc, char **argv)
 	return WERR_OK;
 }
 
-static WERROR cmd_predef(struct regshell_context *ctx, int argc, char **argv)
+static WERROR cmd_predef(struct regshell_context *ctx, int argc, const char **argv)
 {
 	struct registry_key *ret = NULL;
 	if (argc < 2) {
@@ -176,7 +176,7 @@ static WERROR cmd_predef(struct regshell_context *ctx, int argc, char **argv)
 }
 
 static WERROR cmd_pwd(struct regshell_context *ctx,
-		      int argc, char **argv)
+		      int argc, const char **argv)
 {
 	if (ctx->predef) {
 		printf("%s\\", ctx->predef);
@@ -185,7 +185,7 @@ static WERROR cmd_pwd(struct regshell_context *ctx,
 	return WERR_OK;
 }
 
-static WERROR cmd_set(struct regshell_context *ctx, int argc, char **argv)
+static WERROR cmd_set(struct regshell_context *ctx, int argc, const char **argv)
 {
 	struct registry_value val;
 	WERROR error;
@@ -209,7 +209,7 @@ static WERROR cmd_set(struct regshell_context *ctx, int argc, char **argv)
 	return WERR_OK;
 }
 
-static WERROR cmd_ck(struct regshell_context *ctx, int argc, char **argv)
+static WERROR cmd_ck(struct regshell_context *ctx, int argc, const char **argv)
 {
 	struct registry_key *nkey = NULL;
 	char *full_path;
@@ -238,7 +238,7 @@ static WERROR cmd_ck(struct regshell_context *ctx, int argc, char **argv)
 	return WERR_OK;
 }
 
-static WERROR cmd_print(struct regshell_context *ctx, int argc, char **argv)
+static WERROR cmd_print(struct regshell_context *ctx, int argc, const char **argv)
 {
 	uint32_t value_type;
 	DATA_BLOB value_data;
@@ -262,7 +262,7 @@ static WERROR cmd_print(struct regshell_context *ctx, int argc, char **argv)
 	return WERR_OK;
 }
 
-static WERROR cmd_ls(struct regshell_context *ctx, int argc, char **argv)
+static WERROR cmd_ls(struct regshell_context *ctx, int argc, const char **argv)
 {
 	unsigned int i;
 	WERROR error;
@@ -292,7 +292,7 @@ static WERROR cmd_ls(struct regshell_context *ctx, int argc, char **argv)
 
 	return WERR_OK;
 }
-static WERROR cmd_mkkey(struct regshell_context *ctx, int argc, char **argv)
+static WERROR cmd_mkkey(struct regshell_context *ctx, int argc, const char **argv)
 {
 	struct registry_key *tmp;
 	WERROR error;
@@ -314,7 +314,7 @@ static WERROR cmd_mkkey(struct regshell_context *ctx, int argc, char **argv)
 }
 
 static WERROR cmd_rmkey(struct regshell_context *ctx,
-			int argc, char **argv)
+			int argc, const char **argv)
 {
 	WERROR error;
 
@@ -334,7 +334,7 @@ static WERROR cmd_rmkey(struct regshell_context *ctx,
 	return WERR_OK;
 }
 
-static WERROR cmd_rmval(struct regshell_context *ctx, int argc, char **argv)
+static WERROR cmd_rmval(struct regshell_context *ctx, int argc, const char **argv)
 {
 	WERROR error;
 
@@ -355,18 +355,18 @@ static WERROR cmd_rmval(struct regshell_context *ctx, int argc, char **argv)
 }
 
 _NORETURN_ static WERROR cmd_exit(struct regshell_context *ctx,
-				  int argc, char **argv)
+				  int argc, const char **argv)
 {
 	exit(0);
 }
 
-static WERROR cmd_help(struct regshell_context *ctx, int, char **);
+static WERROR cmd_help(struct regshell_context *ctx, int, const char **);
 
 static struct {
 	const char *name;
 	const char *alias;
 	const char *help;
-	WERROR (*handle)(struct regshell_context *ctx, int argc, char **argv);
+	WERROR (*handle)(struct regshell_context *ctx, int argc, const char **argv);
 } regshell_cmds[] = {
 	{"ck", "cd", "Change current key", cmd_ck },
 	{"info", "i", "Show detailed information of a key", cmd_info },
@@ -384,7 +384,7 @@ static struct {
 };
 
 static WERROR cmd_help(struct regshell_context *ctx,
-		       int argc, char **argv)
+		       int argc, const char **argv)
 {
 	unsigned int i;
 	printf("Available commands:\n");
@@ -399,10 +399,10 @@ static WERROR process_cmd(struct regshell_context *ctx,
 			  char *line)
 {
 	int argc;
-	char **argv = NULL;
+	const char **argv = NULL;
 	int ret, i;
 
-	if ((ret = poptParseArgvString(line, &argc, (const char ***) &argv)) != 0) {
+	if ((ret = poptParseArgvString(line, &argc, &argv)) != 0) {
 		fprintf(stderr, "regshell: %s\n", poptStrerror(ret));
 		return WERR_INVALID_PARAM;
 	}
@@ -551,7 +551,7 @@ static char **reg_completion(const char *text, int start, int end)
 	}
 }
 
-int main(int argc, char **argv)
+int main(int argc, const char **argv)
 {
 	int opt;
 	const char *file = NULL;
@@ -570,7 +570,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) {
 	}
diff --git a/source4/lib/registry/tools/regtree.c b/source4/lib/registry/tools/regtree.c
index 40570dd..6df8e50 100644
--- a/source4/lib/registry/tools/regtree.c
+++ b/source4/lib/registry/tools/regtree.c
@@ -98,7 +98,7 @@ static void print_tree(unsigned int level, struct registry_key *p,
 	talloc_free(mem_ctx);
 }
 
-int main(int argc, char **argv)
+int main(int argc, const char **argv)
 {
 	int opt;
 	unsigned int i;
@@ -122,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) {
 	}
-- 
1.9.1


From a853d1b93512769a6e49deb6bae8b8c964fffe7a Mon Sep 17 00:00:00 2001
From: Stefan Metzmacher <metze at samba.org>
Date: Wed, 29 Oct 2014 12:24:44 +0100
Subject: [PATCH 44/64] s4:lib/registry: fix compiler warnings

Signed-off-by: Stefan Metzmacher <metze at samba.org>
---
 source4/lib/registry/regf.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/source4/lib/registry/regf.c b/source4/lib/registry/regf.c
index 544dbb0..8495e53 100644
--- a/source4/lib/registry/regf.c
+++ b/source4/lib/registry/regf.c
@@ -1720,18 +1720,21 @@ static WERROR regf_del_key(TALLOC_CTX *mem_ctx, const struct hive_key *parent,
 	}
 
 	if (key->nk->subkeys_offset != -1) {
-		char *sk_name;
 		struct hive_key *sk = (struct hive_key *)key;
 		unsigned int i = key->nk->num_subkeys;
 		while (i--) {
+			char *sk_name;
+			const char *p = NULL;
+
 			/* Get subkey information. */
 			error = regf_get_subkey_by_index(parent_nk, sk, 0,
-							 (const char **)&sk_name,
+							 &p,
 							 NULL, NULL);
 			if (!W_ERROR_IS_OK(error)) {
 				DEBUG(0, ("Can't retrieve subkey by index.\n"));
 				return error;
 			}
+			sk_name = discard_const_p(char, p);
 
 			/* Delete subkey. */
 			error = regf_del_key(NULL, sk, sk_name);
@@ -1745,19 +1748,22 @@ static WERROR regf_del_key(TALLOC_CTX *mem_ctx, const struct hive_key *parent,
 	}
 
 	if (key->nk->values_offset != -1) {
-		char *val_name;
 		struct hive_key *sk = (struct hive_key *)key;
 		DATA_BLOB data;
 		unsigned int i = key->nk->num_values;
 		while (i--) {
+			char *val_name;
+			const char *p = NULL;
+
 			/* Get value information. */
 			error = regf_get_value(parent_nk, sk, 0,
-					       (const char **)&val_name,
+					       &p,
 					       NULL, &data);
 			if (!W_ERROR_IS_OK(error)) {
 				DEBUG(0, ("Can't retrieve value by index.\n"));
 				return error;
 			}
+			val_name = discard_const_p(char, p);
 
 			/* Delete value. */
 			error = regf_del_value(NULL, sk, val_name);
-- 
1.9.1


From 2b9c75735ddf075137bc91e393feffe4eaadeeb8 Mon Sep 17 00:00:00 2001
From: Stefan Metzmacher <metze at samba.org>
Date: Wed, 29 Oct 2014 12:25:24 +0100
Subject: [PATCH 45/64] s4:lib/registry: remove unused allow_warnings=True

Signed-off-by: Stefan Metzmacher <metze at samba.org>
---
 source4/lib/registry/wscript_build | 1 -
 1 file changed, 1 deletion(-)

diff --git a/source4/lib/registry/wscript_build b/source4/lib/registry/wscript_build
index 0055e2e..495969a 100644
--- a/source4/lib/registry/wscript_build
+++ b/source4/lib/registry/wscript_build
@@ -12,7 +12,6 @@ bld.SAMBA_SUBSYSTEM('TDR_REGF',
 
 bld.SAMBA_LIBRARY('registry',
 	source='interface.c util.c samba.c patchfile_dotreg.c patchfile_preg.c patchfile.c regf.c hive.c local.c ldb.c rpc.c',
-	allow_warnings=True,
 	pc_files='registry.pc',
 	public_deps='dcerpc samba-util TDR_REGF ldb RPC_NDR_WINREG ldbsamba util_reg',
 	public_headers='registry.h',
-- 
1.9.1


From bdd1d4172a407196bc08b99255e5bfcffd8a1972 Mon Sep 17 00:00:00 2001
From: Stefan Metzmacher <metze at samba.org>
Date: Thu, 27 Feb 2014 09:50:57 +0100
Subject: [PATCH 46/64] s4:libcli/raw: use smb_setfsinfo_level in smb_setfsinfo

Signed-off-by: Stefan Metzmacher <metze at samba.org>
---
 source4/libcli/raw/interfaces.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/source4/libcli/raw/interfaces.h b/source4/libcli/raw/interfaces.h
index 9003c12..03e9bbb 100644
--- a/source4/libcli/raw/interfaces.h
+++ b/source4/libcli/raw/interfaces.h
@@ -1339,12 +1339,12 @@ enum smb_setfsinfo_level {
 union smb_setfsinfo {
 	/* generic interface */
 	struct {
-		enum smb_fsinfo_level level;
+		enum smb_setfsinfo_level level;
 	} generic;
 
 	/* TRANS2 RAW_QFS_UNIX_INFO interface */
 	struct {
-		enum smb_fsinfo_level level;
+		enum smb_setfsinfo_level level;
 
 		struct {
 			uint16_t major_version;
-- 
1.9.1


From 3851feb433a42e8c3b79b41d1bcff3f577e7d7be Mon Sep 17 00:00:00 2001
From: Stefan Metzmacher <metze at samba.org>
Date: Thu, 27 Feb 2014 09:29:36 +0100
Subject: [PATCH 47/64] s4:kdc: comment out unused code in db-glue.c

Signed-off-by: Stefan Metzmacher <metze at samba.org>
---
 source4/kdc/db-glue.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/source4/kdc/db-glue.c b/source4/kdc/db-glue.c
index b0c3e7a..00b58fd 100644
--- a/source4/kdc/db-glue.c
+++ b/source4/kdc/db-glue.c
@@ -1362,10 +1362,10 @@ static krb5_error_code samba_kdc_lookup_server(krb5_context context,
 	} else {
 		int lret;
 		char *short_princ;
-		const char *realm;
+		/* const char *realm; */
 		/* server as client principal case, but we must not lookup userPrincipalNames */
 		*realm_dn = ldb_get_default_basedn(kdc_db_ctx->samdb);
-		realm = krb5_principal_get_realm(context, principal);
+		/* realm = krb5_principal_get_realm(context, principal); */
 
 		/* TODO: Check if it is our realm, otherwise give referral */
 
-- 
1.9.1


From ad8411ecd12e69efa24125db7ef1f2cf39fb46a8 Mon Sep 17 00:00:00 2001
From: Stefan Metzmacher <metze at samba.org>
Date: Wed, 29 Oct 2014 12:21:07 +0100
Subject: [PATCH 48/64] s4:kdc: remove unused allow_warnings=True for
 'MIT_SAMBA'

Signed-off-by: Stefan Metzmacher <metze at samba.org>
---
 source4/kdc/wscript_build | 1 -
 1 file changed, 1 deletion(-)

diff --git a/source4/kdc/wscript_build b/source4/kdc/wscript_build
index c77f2a2..78a79b7 100755
--- a/source4/kdc/wscript_build
+++ b/source4/kdc/wscript_build
@@ -62,7 +62,6 @@ bld.SAMBA_LIBRARY('db-glue',
 
 bld.SAMBA_SUBSYSTEM('MIT_SAMBA',
 	source='mit_samba.c',
-	allow_warnings=True,
 	deps='ldb auth4_sam auth_sam_reply samba-credentials hdb db-glue PAC_GLUE samba-hostconfig com_err'
 	)
 
-- 
1.9.1


From d0621006ef41ef3caa827bfc0b94329419597271 Mon Sep 17 00:00:00 2001
From: Stefan Metzmacher <metze at samba.org>
Date: Thu, 27 Feb 2014 09:29:36 +0100
Subject: [PATCH 49/64] s4:nbt_server: avoid str_list related const warning

Signed-off-by: Stefan Metzmacher <metze at samba.org>
---
 source4/nbt_server/wins/winsclient.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/source4/nbt_server/wins/winsclient.c b/source4/nbt_server/wins/winsclient.c
index b047b2b..0636594 100644
--- a/source4/nbt_server/wins/winsclient.c
+++ b/source4/nbt_server/wins/winsclient.c
@@ -142,6 +142,7 @@ static void nbtd_wins_refresh(struct tevent_context *ev, struct tevent_timer *te
 	struct nbt_name_socket *nbtsock = wins_socket(iface);
 	struct tevent_req *subreq;
 	struct nbtd_wins_refresh_state *state;
+	char **l;
 
 	state = talloc_zero(iname, struct nbtd_wins_refresh_state);
 	if (state == NULL) {
@@ -152,7 +153,8 @@ static void nbtd_wins_refresh(struct tevent_context *ev, struct tevent_timer *te
 
 	/* setup a wins name refresh request */
 	state->io.in.name            = iname->name;
-	state->io.in.wins_servers    = (const char **)str_list_make_single(state, iname->wins_server);
+	l = str_list_make_single(state, iname->wins_server);
+	state->io.in.wins_servers    = discard_const_p(const char *, l);
 	state->io.in.wins_port       = lpcfg_nbt_port(iface->nbtsrv->task->lp_ctx);
 	state->io.in.addresses       = nbtd_address_list(iface, state);
 	state->io.in.nb_flags        = iname->nb_flags;
-- 
1.9.1


From b8b8edaf5d8181a1977922d4e854f484fc2bfc67 Mon Sep 17 00:00:00 2001
From: Stefan Metzmacher <metze at samba.org>
Date: Thu, 27 Feb 2014 09:29:36 +0100
Subject: [PATCH 50/64] s4:ntvfs: explicitly handle
 RAW_FILEINFO_UNIX_{BASIC,LINK} in ntvfs_map_fileinfo()

This avoids compiler warnings.

Signed-off-by: Stefan Metzmacher <metze at samba.org>
---
 source4/ntvfs/ntvfs_generic.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/source4/ntvfs/ntvfs_generic.c b/source4/ntvfs/ntvfs_generic.c
index 0854aa3..d3f7919 100644
--- a/source4/ntvfs/ntvfs_generic.c
+++ b/source4/ntvfs/ntvfs_generic.c
@@ -908,8 +908,10 @@ NTSTATUS ntvfs_map_fileinfo(TALLOC_CTX *mem_ctx,
 		info->alignment_information.out.alignment_requirement =
 			info2->generic.out.alignment_requirement;
 		return NT_STATUS_OK;
-#if 0	
 	case RAW_FILEINFO_UNIX_BASIC:
+#if 1
+		return NT_STATUS_INVALID_LEVEL;
+#else
 		info->unix_basic_info.out.end_of_file = info2->generic.out.end_of_file;
 		info->unix_basic_info.out.num_bytes = info2->generic.out.size;
 		info->unix_basic_info.out.status_change_time = info2->generic.out.change_time;
@@ -924,8 +926,11 @@ NTSTATUS ntvfs_map_fileinfo(TALLOC_CTX *mem_ctx,
 		info->unix_basic_info.out.permissions = info2->generic.out.permissions;
 		info->unix_basic_info.out.nlink = info2->generic.out.nlink;
 		return NT_STATUS_OK;
-		
+#endif
 	case RAW_FILEINFO_UNIX_LINK:
+#if 1
+		return NT_STATUS_INVALID_LEVEL;
+#else
 		info->unix_link_info.out.link_dest = info2->generic.out.link_dest;
 		return NT_STATUS_OK;
 #endif
-- 
1.9.1


From f5ee6d4c2f302345667f3b1907c07621ce57ba08 Mon Sep 17 00:00:00 2001
From: Stefan Metzmacher <metze at samba.org>
Date: Thu, 27 Feb 2014 09:29:36 +0100
Subject: [PATCH 51/64] s4:ntvfs/smb2: ifdef out unused code

Signed-off-by: Stefan Metzmacher <metze at samba.org>
---
 source4/ntvfs/smb2/vfs_smb2.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/source4/ntvfs/smb2/vfs_smb2.c b/source4/ntvfs/smb2/vfs_smb2.c
index a3a670a..dbb76b3 100644
--- a/source4/ntvfs/smb2/vfs_smb2.c
+++ b/source4/ntvfs/smb2/vfs_smb2.c
@@ -100,6 +100,7 @@ struct async_info {
   a handler for oplock break events from the server - these need to be passed
   along to the client
  */
+#if 0
 static bool oplock_handler(struct smbcli_transport *transport, uint16_t tid, uint16_t fnum, uint8_t level, void *p_private)
 {
 	struct cvfs_private *p = p_private;
@@ -123,6 +124,7 @@ static bool oplock_handler(struct smbcli_transport *transport, uint16_t tid, uin
 	if (!NT_STATUS_IS_OK(status)) return false;
 	return true;
 }
+#endif
 
 /*
   return a handle to the root of the share
-- 
1.9.1


From 060c6aadcaae151e7f2d039fb8fb68de8bb925ff Mon Sep 17 00:00:00 2001
From: Stefan Metzmacher <metze at samba.org>
Date: Thu, 27 Feb 2014 09:08:17 +0100
Subject: [PATCH 52/64] s4:smb_server/smb2: avoid unused warnings in
 smb2srv_setinfo_send()

op->req and req have the same value.

Signed-off-by: Stefan Metzmacher <metze at samba.org>
---
 source4/smb_server/smb2/fileinfo.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/source4/smb_server/smb2/fileinfo.c b/source4/smb_server/smb2/fileinfo.c
index 5e4f35e..8c49336 100644
--- a/source4/smb_server/smb2/fileinfo.c
+++ b/source4/smb_server/smb2/fileinfo.c
@@ -250,7 +250,7 @@ static void smb2srv_setinfo_send(struct ntvfs_request *ntvfs)
 
 	SMB2SRV_CHECK_ASYNC_STATUS(op, struct smb2srv_setinfo_op);
 
-	SMB2SRV_CHECK(smb2srv_setup_reply(req, 0x02, false, 0));
+	SMB2SRV_CHECK(smb2srv_setup_reply(op->req, 0x02, false, 0));
 
 	smb2srv_send_reply(req);
 }
-- 
1.9.1


From 1dcf08f4c1e3a33992000f57f50b73eb51089a5c Mon Sep 17 00:00:00 2001
From: Stefan Metzmacher <metze at samba.org>
Date: Thu, 27 Feb 2014 09:08:17 +0100
Subject: [PATCH 53/64] s4:smb_server/smb2: remove unused _pad variables

Signed-off-by: Stefan Metzmacher <metze at samba.org>
---
 source4/smb_server/smb2/keepalive.c | 4 ----
 source4/smb_server/smb2/sesssetup.c | 4 ----
 source4/smb_server/smb2/tcon.c      | 4 ----
 3 files changed, 12 deletions(-)

diff --git a/source4/smb_server/smb2/keepalive.c b/source4/smb_server/smb2/keepalive.c
index c362acb..cd53778 100644
--- a/source4/smb_server/smb2/keepalive.c
+++ b/source4/smb_server/smb2/keepalive.c
@@ -51,8 +51,6 @@ static void smb2srv_keepalive_send(struct smb2srv_request *req)
 
 void smb2srv_keepalive_recv(struct smb2srv_request *req)
 {
-	uint16_t _pad;
-
 	if (req->in.body_size != 0x04) {
 		smb2srv_send_error(req,  NT_STATUS_INVALID_PARAMETER);
 		return;
@@ -63,8 +61,6 @@ void smb2srv_keepalive_recv(struct smb2srv_request *req)
 		return;
 	}
 
-	_pad	= SVAL(req->in.body, 0x02);
-
 	req->status = smb2srv_keepalive_backend(req);
 
 	if (req->control_flags & SMB2SRV_REQ_CTRL_FLAG_NOT_REPLY) {
diff --git a/source4/smb_server/smb2/sesssetup.c b/source4/smb_server/smb2/sesssetup.c
index 35a1484..d4b8de6 100644
--- a/source4/smb_server/smb2/sesssetup.c
+++ b/source4/smb_server/smb2/sesssetup.c
@@ -282,12 +282,8 @@ static void smb2srv_logoff_send(struct smb2srv_request *req)
 
 void smb2srv_logoff_recv(struct smb2srv_request *req)
 {
-	uint16_t _pad;
-
 	SMB2SRV_CHECK_BODY_SIZE(req, 0x04, false);
 
-	_pad	= SVAL(req->in.body, 0x02);
-
 	req->status = smb2srv_logoff_backend(req);
 
 	if (req->control_flags & SMB2SRV_REQ_CTRL_FLAG_NOT_REPLY) {
diff --git a/source4/smb_server/smb2/tcon.c b/source4/smb_server/smb2/tcon.c
index e7d2847..b2d1043 100644
--- a/source4/smb_server/smb2/tcon.c
+++ b/source4/smb_server/smb2/tcon.c
@@ -434,12 +434,8 @@ static void smb2srv_tdis_send(struct smb2srv_request *req)
 
 void smb2srv_tdis_recv(struct smb2srv_request *req)
 {
-	uint16_t _pad;
-
 	SMB2SRV_CHECK_BODY_SIZE(req, 0x04, false);
 
-	_pad	= SVAL(req->in.body, 0x02);
-
 	req->status = smb2srv_tdis_backend(req);
 
 	if (req->control_flags & SMB2SRV_REQ_CTRL_FLAG_NOT_REPLY) {
-- 
1.9.1


From 719408f7c955a7c3bd038196e9b41a7545f8371f Mon Sep 17 00:00:00 2001
From: Stefan Metzmacher <metze at samba.org>
Date: Thu, 27 Feb 2014 09:08:17 +0100
Subject: [PATCH 54/64] s4:torture/locktest: comment out unused code and avoid
 smbcli_nt_error()

Signed-off-by: Stefan Metzmacher <metze at samba.org>
---
 source4/torture/locktest.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/source4/torture/locktest.c b/source4/torture/locktest.c
index 0d2608f..ac8d854a 100644
--- a/source4/torture/locktest.c
+++ b/source4/torture/locktest.c
@@ -221,7 +221,7 @@ static bool test_one(struct smbcli_state *cli[NSERVERS][NCONNECTIONS],
 	uint64_t len = rec->len;
 	enum brl_type op = rec->lock_type;
 	int server;
-	bool ret[NSERVERS];
+	/* bool ret[NSERVERS]; */
 	NTSTATUS status[NSERVERS];
 
 	switch (rec->lock_op) {
@@ -256,8 +256,8 @@ static bool test_one(struct smbcli_state *cli[NSERVERS][NCONNECTIONS],
 				res = smb_raw_lock(tree, &parms);
 			}
 
-			ret[server] = NT_STATUS_IS_OK(res); 
-			status[server] = smbcli_nt_error(cli[server][conn]->tree);
+			/* ret[server] = NT_STATUS_IS_OK(res); */
+			status[server] = res;
 			if (!exact_error_codes && 
 			    NT_STATUS_EQUAL(status[server], 
 					    NT_STATUS_FILE_LOCK_CONFLICT)) {
@@ -302,8 +302,8 @@ static bool test_one(struct smbcli_state *cli[NSERVERS][NCONNECTIONS],
 				res = smb_raw_lock(tree, &parms);
 			}
 
-			ret[server] = NT_STATUS_IS_OK(res);
-			status[server] = smbcli_nt_error(cli[server][conn]->tree);
+			/* ret[server] = NT_STATUS_IS_OK(res); */
+			status[server] = res;
 		}
 		if (showall || 
 		    (!hide_unlock_fails && !NT_STATUS_EQUAL(status[0],status[1]))) {
-- 
1.9.1


From 4692c8034fd8305a8533ac410f7f797d18fdc9d2 Mon Sep 17 00:00:00 2001
From: Stefan Metzmacher <metze at samba.org>
Date: Wed, 29 Oct 2014 11:39:39 +0100
Subject: [PATCH 55/64] s4:torture/winbind: remove unused variables in
 struct_based.c

Signed-off-by: Stefan Metzmacher <metze at samba.org>
---
 source4/torture/winbind/struct_based.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/source4/torture/winbind/struct_based.c b/source4/torture/winbind/struct_based.c
index ef27b05..2bd7443 100644
--- a/source4/torture/winbind/struct_based.c
+++ b/source4/torture/winbind/struct_based.c
@@ -52,9 +52,10 @@
 	} \
 } while(0)
 
+#undef _STRUCT_NOOP
+#define _STRUCT_NOOP do {} while(0);
 #define DO_STRUCT_REQ_REP(op,req,rep) do { \
-	bool __noop = false; \
-	DO_STRUCT_REQ_REP_EXT(op,req,rep,NSS_STATUS_SUCCESS,true,__noop=true,NULL); \
+	DO_STRUCT_REQ_REP_EXT(op,req,rep,NSS_STATUS_SUCCESS,true, _STRUCT_NOOP, NULL); \
 } while (0)
 
 static bool torture_winbind_struct_interface_version(struct torture_context *torture)
@@ -853,9 +854,8 @@ static bool torture_winbind_struct_getpwent(struct torture_context *torture)
 	ZERO_STRUCT(rep);
 	req.data.num_entries = 1;
 	if (torture_setting_bool(torture, "samba3", false)) {
-		bool __noop = false;
 		DO_STRUCT_REQ_REP_EXT(WINBINDD_GETPWENT, &req, &rep,
-				      NSS_STATUS_SUCCESS, false, __noop=true,
+				      NSS_STATUS_SUCCESS, false, _STRUCT_NOOP,
 				      NULL);
 	} else {
 		DO_STRUCT_REQ_REP(WINBINDD_GETPWENT, &req, &rep);
-- 
1.9.1


From 2942bce71eb21fdf563f57637888756d682233fd Mon Sep 17 00:00:00 2001
From: Stefan Metzmacher <metze at samba.org>
Date: Wed, 29 Oct 2014 12:26:38 +0100
Subject: [PATCH 56/64] s4:torture: remove unused allow_warnings=True for
 'TORTURE_BASIC' and 'TORTURE_VFS'

Signed-off-by: Stefan Metzmacher <metze at samba.org>
---
 source4/torture/wscript_build | 2 --
 1 file changed, 2 deletions(-)

diff --git a/source4/torture/wscript_build b/source4/torture/wscript_build
index c13e7d4..aa5784a 100755
--- a/source4/torture/wscript_build
+++ b/source4/torture/wscript_build
@@ -10,7 +10,6 @@ bld.SAMBA_SUBSYSTEM('TORTURE_UTIL',
 
 bld.SAMBA_MODULE('TORTURE_BASIC',
 	source='basic/base.c basic/misc.c basic/scanner.c basic/utable.c basic/charset.c basic/mangle_test.c basic/denytest.c basic/aliases.c basic/locking.c basic/secleak.c basic/rename.c basic/dir.c basic/delete.c basic/unlink.c basic/disconnect.c basic/delaywrite.c basic/attr.c basic/properties.c',
-	allow_warnings=True,
 	subsystem='smbtorture',
 	deps='LIBCLI_SMB popt POPT_CREDENTIALS TORTURE_UTIL smbclient-raw TORTURE_RAW',
 	internal_module=True,
@@ -152,7 +151,6 @@ bld.SAMBA_MODULE('TORTURE_NTP',
 
 bld.SAMBA_MODULE('TORTURE_VFS',
 	source='vfs/vfs.c vfs/fruit.c',
-	allow_warnings=True,
 	subsystem='smbtorture',
 	deps='LIBCLI_SMB POPT_CREDENTIALS TORTURE_UTIL smbclient-raw TORTURE_RAW',
 	internal_module=True,
-- 
1.9.1


From 0711050ce89ead044cf3c52e9b26826326be5943 Mon Sep 17 00:00:00 2001
From: Stefan Metzmacher <metze at samba.org>
Date: Thu, 22 May 2014 10:41:33 +0200
Subject: [PATCH 57/64] wafsamba: use -Wno-error=deprecated-declarations in
 picky-developer mode

Currently we use too many deprecated function like
dcerpc_binding_handle_set_sync_ev() and others, but this should not be a reason
to require 'allow_warnings=True'.

Signed-off-by: Stefan Metzmacher <metze at samba.org>
---
 buildtools/wafsamba/samba_autoconf.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/buildtools/wafsamba/samba_autoconf.py b/buildtools/wafsamba/samba_autoconf.py
index c193873..c818025 100644
--- a/buildtools/wafsamba/samba_autoconf.py
+++ b/buildtools/wafsamba/samba_autoconf.py
@@ -691,7 +691,7 @@ int main(void) {
             conf.env['EXTRA_CFLAGS'].extend(TO_LIST("-Werror=format"))
 
     if Options.options.picky_developer:
-        conf.ADD_NAMED_CFLAGS('PICKY_CFLAGS', '-Werror', testflags=True)
+        conf.ADD_NAMED_CFLAGS('PICKY_CFLAGS', '-Werror -Wno-error=deprecated-declarations', testflags=True)
 
     if Options.options.fatal_errors:
         conf.ADD_CFLAGS('-Wfatal-errors', testflags=True)
-- 
1.9.1


From a6b3383760e29d047fb020c6aca535ad0e4cf143 Mon Sep 17 00:00:00 2001
From: Stefan Metzmacher <metze at samba.org>
Date: Wed, 29 Oct 2014 12:27:28 +0100
Subject: [PATCH 58/64] s4:lib/events: remove unused allow_warnings=True

Signed-off-by: Stefan Metzmacher <metze at samba.org>
---
 source4/lib/events/wscript_build | 1 -
 1 file changed, 1 deletion(-)

diff --git a/source4/lib/events/wscript_build b/source4/lib/events/wscript_build
index 355f315..d08d5dd 100644
--- a/source4/lib/events/wscript_build
+++ b/source4/lib/events/wscript_build
@@ -5,6 +5,5 @@ bld.SAMBA_LIBRARY('events',
                   source='tevent_s4.c',
                   deps='samba-util',
                   public_deps='tevent',
-                  allow_warnings=True,
                   private_library=True
                   )
-- 
1.9.1


From b7fde0b05741f696d30244475004522b7bfaa5a4 Mon Sep 17 00:00:00 2001
From: Stefan Metzmacher <metze at samba.org>
Date: Wed, 29 Oct 2014 12:27:28 +0100
Subject: [PATCH 59/64] s4:lib/messaging: remove unused allow_warnings=True

Signed-off-by: Stefan Metzmacher <metze at samba.org>
---
 source4/lib/messaging/wscript_build | 1 -
 1 file changed, 1 deletion(-)

diff --git a/source4/lib/messaging/wscript_build b/source4/lib/messaging/wscript_build
index c1b7e1e..31a97a2 100644
--- a/source4/lib/messaging/wscript_build
+++ b/source4/lib/messaging/wscript_build
@@ -4,7 +4,6 @@
 bld.SAMBA_LIBRARY('MESSAGING',
 	source='messaging.c',
 	public_deps='samba-util tdb-wrap NDR_IRPC UNIX_PRIVS util_tdb cluster ndr samba_socket dcerpc',
-	allow_warnings=True,
 	private_library=True
 	)
 
-- 
1.9.1


From 7a142a499385b78c243d064ffafcc69250548114 Mon Sep 17 00:00:00 2001
From: Stefan Metzmacher <metze at samba.org>
Date: Wed, 29 Oct 2014 12:27:28 +0100
Subject: [PATCH 60/64] s4:librpc: remove unused allow_warnings=True for
 'dcerpc'

Signed-off-by: Stefan Metzmacher <metze at samba.org>
---
 source4/librpc/wscript_build | 1 -
 1 file changed, 1 deletion(-)

diff --git a/source4/librpc/wscript_build b/source4/librpc/wscript_build
index ea81d2c..9b96437 100755
--- a/source4/librpc/wscript_build
+++ b/source4/librpc/wscript_build
@@ -123,7 +123,6 @@ bld.SAMBA_LIBRARY('dcerpc',
 	rpc/dcerpc_connect.c rpc/dcerpc_secondary.c''',
 	pc_files='dcerpc.pc',
 	deps='samba_socket LIBCLI_RESOLVE LIBCLI_SMB LIBCLI_SMB2 ndr NDR_DCERPC RPC_NDR_EPMAPPER NDR_SCHANNEL RPC_NDR_NETLOGON RPC_NDR_MGMT gensec LIBCLI_AUTH smbclient-raw LP_RESOLVE tevent-util dcerpc-binding param_options http',
-	allow_warnings=True,
 	autoproto='rpc/dcerpc_proto.h',
 	public_deps='samba-credentials tevent talloc',
 	public_headers='''rpc/dcerpc.h ../../librpc/gen_ndr/mgmt.h
-- 
1.9.1


From 131adf544b65c216ed04eaf16afb81b3e17dcafb Mon Sep 17 00:00:00 2001
From: Stefan Metzmacher <metze at samba.org>
Date: Wed, 29 Oct 2014 12:27:28 +0100
Subject: [PATCH 61/64] s4:ntvfs/unixuid: remove unused allow_warnings=True

Signed-off-by: Stefan Metzmacher <metze at samba.org>
---
 source4/ntvfs/unixuid/wscript_build | 1 -
 1 file changed, 1 deletion(-)

diff --git a/source4/ntvfs/unixuid/wscript_build b/source4/ntvfs/unixuid/wscript_build
index f014674..56fd42d 100644
--- a/source4/ntvfs/unixuid/wscript_build
+++ b/source4/ntvfs/unixuid/wscript_build
@@ -2,7 +2,6 @@
 
 bld.SAMBA_MODULE('ntvfs_unixuid',
 	source='vfs_unixuid.c',
-	allow_warnings=True,
 	subsystem='ntvfs',
 	init_function='ntvfs_unixuid_init',
 	deps='auth_unix_token talloc'
-- 
1.9.1


From f3af38a0c1ce58261f58a2173bd86d9ba8778903 Mon Sep 17 00:00:00 2001
From: Stefan Metzmacher <metze at samba.org>
Date: Wed, 26 Feb 2014 07:34:51 +0100
Subject: [PATCH 62/64] wafsamba: change the default to allow_warnings=False
 for SAMBA_{SUBSYSTEM,LIBRARY,MODULE}()

Signed-off-by: Stefan Metzmacher <metze at samba.org>
---
 buildtools/wafsamba/wafsamba.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/buildtools/wafsamba/wafsamba.py b/buildtools/wafsamba/wafsamba.py
index b68b9d2..020516b 100644
--- a/buildtools/wafsamba/wafsamba.py
+++ b/buildtools/wafsamba/wafsamba.py
@@ -132,7 +132,7 @@ def SAMBA_LIBRARY(bld, libname, source,
                   private_library=False,
                   grouping_library=False,
                   allow_undefined_symbols=False,
-                  allow_warnings=True,
+                  allow_warnings=False,
                   enabled=True):
     '''define a Samba library'''
 
@@ -420,7 +420,7 @@ def SAMBA_MODULE(bld, modname, source,
                  pyembed=False,
                  manpages=None,
                  allow_undefined_symbols=False,
-                 allow_warnings=True
+                 allow_warnings=False
                  ):
     '''define a Samba module.'''
 
@@ -520,7 +520,7 @@ def SAMBA_SUBSYSTEM(bld, modname, source,
                     vars=None,
                     subdir=None,
                     hide_symbols=False,
-                    allow_warnings=True,
+                    allow_warnings=False,
                     pyext=False,
                     pyembed=False):
     '''define a Samba subsystem'''
-- 
1.9.1


From 245a2e992e6096048c60a2915286b45dd952e873 Mon Sep 17 00:00:00 2001
From: Stefan Metzmacher <metze at samba.org>
Date: Wed, 26 Feb 2014 07:34:51 +0100
Subject: [PATCH 63/64] wafsamba: change the default to allow_warnings=False
 for CURRENT_CFLAGS()

Signed-off-by: Stefan Metzmacher <metze at samba.org>
---
 buildtools/wafsamba/samba_autoconf.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/buildtools/wafsamba/samba_autoconf.py b/buildtools/wafsamba/samba_autoconf.py
index c818025..9e50ee5 100644
--- a/buildtools/wafsamba/samba_autoconf.py
+++ b/buildtools/wafsamba/samba_autoconf.py
@@ -765,7 +765,7 @@ def ADD_EXTRA_INCLUDES(conf, includes):
 
 
 
-def CURRENT_CFLAGS(bld, target, cflags, allow_warnings=True, hide_symbols=False):
+def CURRENT_CFLAGS(bld, target, cflags, allow_warnings=False, hide_symbols=False):
     '''work out the current flags. local flags are added first'''
     ret = TO_LIST(cflags)
     if not 'EXTRA_CFLAGS' in bld.env:
-- 
1.9.1


From 000c3d09399024d83af81feadc9c20e28c7392bc Mon Sep 17 00:00:00 2001
From: Stefan Metzmacher <metze at samba.org>
Date: Tue, 11 Nov 2014 14:54:41 +0100
Subject: [PATCH 64/64] script/autobuild.py: build 'samba' using
 --picky-developer

This makes sure we don't get unexpected new compiler warnings.

Signed-off-by: Stefan Metzmacher <metze at samba.org>
---
 script/autobuild.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/script/autobuild.py b/script/autobuild.py
index 2b25a10..ba08e52 100755
--- a/script/autobuild.py
+++ b/script/autobuild.py
@@ -44,7 +44,7 @@ tasks = {
                ("clean", "make clean", "text/plain") ],
 
     # We have 'test' before 'install' because, 'test' should work without 'install'
-    "samba" : [ ("configure", "./configure.developer ${PREFIX} --with-selftest-prefix=./bin/ab", "text/plain"),
+    "samba" : [ ("configure", "./configure.developer --picky-developer ${PREFIX} --with-selftest-prefix=./bin/ab", "text/plain"),
                 ("make", "make -j", "text/plain"),
                 ("test", "make test FAIL_IMMEDIATELY=1", "text/plain"),
                 ("install", "make install", "text/plain"),
-- 
1.9.1
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: OpenPGP digital signature
URL: <http://lists.samba.org/pipermail/samba-technical/attachments/20141111/ded6c4ca/attachment-0001.pgp>


More information about the samba-technical mailing list