[PATCHES v2] Fix compilation on i386

Douglas Bagnall douglas.bagnall at catalyst.net.nz
Wed Jun 17 15:48:00 MDT 2015


With the improvements suggested by Metze and his reviewed-by.

Douglas

On 17/06/15 16:23, Douglas Bagnall wrote:
> Running an autobuild on an i386 threw up a few -WError issues,
> which in turn lead to some very minor formatting improvements.
> 
> Through misadventure I managed to trigger an attempt to compile the
> replacement snprintf library, which also failed -WError (on discarded
> const, not obviously 32 bit related). But I haven't found a sensible way
> of doing that reliably, so I'm pretending it didn't happen for now.


-------------- next part --------------
From 50c869a294ea3203dc4cd1c673fcba4776e437ec Mon Sep 17 00:00:00 2001
From: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Date: Wed, 17 Jun 2015 11:37:03 +1200
Subject: [PATCH 1/5] Treat unsigned 64 bit IDL values as unsigned long long in
 Python

This caused a compilation error on i386:

default/librpc/gen_ndr/py_server_id.c:216:75: error: overflow in implicit constant conversion [-Werror=overflow]
  PyModule_AddObject(m, "SERVERID_UNIQUE_ID_NOT_TO_VERIFY", PyInt_FromLong(0xFFFFFFFFFFFFFFFFULL));

Signed-off-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Reviewed-by: Stefan Metzmacher <metze at samba.org>
---
 pidl/lib/Parse/Pidl/Samba4/Python.pm | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/pidl/lib/Parse/Pidl/Samba4/Python.pm b/pidl/lib/Parse/Pidl/Samba4/Python.pm
index b0a7099..7521d61 100644
--- a/pidl/lib/Parse/Pidl/Samba4/Python.pm
+++ b/pidl/lib/Parse/Pidl/Samba4/Python.pm
@@ -1199,10 +1199,14 @@ sub ConvertScalarToPython($$$)
 
 	$ctypename = expandAlias($ctypename);
 
-	if ($ctypename =~ /^(u?int64|hyper|dlong|udlong|udlongr|NTTIME_hyper|NTTIME|NTTIME_1sec)$/) {
+	if ($ctypename =~ /^(int64|dlong)$/) {
 		return "PyLong_FromLongLong($cvar)";
 	}
 
+	if ($ctypename =~ /^(uint64|hyper|udlong|udlongr|NTTIME_hyper|NTTIME|NTTIME_1sec)$/) {
+		return "PyLong_FromUnsignedLongLong($cvar)";
+	}
+
 	if ($ctypename =~ /^(char|u?int[0-9]*|time_t|uid_t|gid_t)$/) {
 		return "PyInt_FromLong($cvar)";
 	}
-- 
1.9.1


From ac0cf14398eb29050f4fa4ab400f23a3d7aabf77 Mon Sep 17 00:00:00 2001
From: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Date: Wed, 17 Jun 2015 16:07:00 +1200
Subject: [PATCH 2/5] remove trailing whitespace in Pidl/Samba4/Python.pm

Signed-off-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Reviewed-by: Stefan Metzmacher <metze at samba.org>
---
 pidl/lib/Parse/Pidl/Samba4/Python.pm | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/pidl/lib/Parse/Pidl/Samba4/Python.pm b/pidl/lib/Parse/Pidl/Samba4/Python.pm
index 7521d61..0f54944 100644
--- a/pidl/lib/Parse/Pidl/Samba4/Python.pm
+++ b/pidl/lib/Parse/Pidl/Samba4/Python.pm
@@ -112,7 +112,7 @@ sub EnumAndBitmapConsts($$$)
 	foreach my $e (@{$d->{ELEMENTS}}) {
 		$e =~ /^([A-Za-z0-9_]+)/;
 		my $cname = $1;
-		
+
 		$self->register_constant($cname, $d, $cname);
 	}
 }
@@ -221,7 +221,7 @@ sub PythonStruct($$$$$$)
 			my $mem_ctx = "pytalloc_get_mem_ctx(py_obj)";
 			my $l = $e->{LEVELS}[0];
 			my $nl = GetNextLevel($e, $l);
-			if ($l->{TYPE} eq "POINTER" and 
+			if ($l->{TYPE} eq "POINTER" and
 				not ($nl->{TYPE} eq "ARRAY" and ($nl->{IS_FIXED} or is_charset_array($e, $nl))) and
 				not ($nl->{TYPE} eq "DATA" and Parse::Pidl::Typelist::scalar_is_reference($nl->{DATA_TYPE}))) {
 				$self->pidl("talloc_unlink(pytalloc_get_mem_ctx(py_obj), discard_const($varname));");
@@ -255,7 +255,7 @@ sub PythonStruct($$$$$$)
 
 	my $py_methods = "NULL";
 
-	# If the struct is not public there ndr_pull/ndr_push functions will 
+	# If the struct is not public there ndr_pull/ndr_push functions will
 	# be static so not callable from here
 	if (has_property($d, "public")) {
 		$self->pidl("static PyObject *py_$name\_ndr_pack(PyObject *py_obj)");
@@ -405,8 +405,8 @@ sub find_metadata_args($)
 	foreach my $e (@{$fn->{ELEMENTS}}) {
 		foreach my $dir (@{$e->{DIRECTION}}) {
 			 my $main = get_metadata_var($e);
-			 if ($main) { 
-				 $metadata_args->{$dir}->{$main} = $e->{NAME}; 
+			 if ($main) {
+				 $metadata_args->{$dir}->{$main} = $e->{NAME};
 			 }
 		 }
 	}
@@ -432,7 +432,7 @@ sub PythonFunctionUnpackOut($$$)
 	$self->pidl("PyObject *result;");
 	foreach my $e (@{$fn->{ELEMENTS}}) {
 		next unless (grep(/out/,@{$e->{DIRECTION}}));
-		next if (($metadata_args->{in}->{$e->{NAME}} and grep(/in/, @{$e->{DIRECTION}})) or 
+		next if (($metadata_args->{in}->{$e->{NAME}} and grep(/in/, @{$e->{DIRECTION}})) or
 		         ($metadata_args->{out}->{$e->{NAME}}) and grep(/out/, @{$e->{DIRECTION}}));
 		$self->pidl("PyObject *py_$e->{NAME};");
 		$result_size++;
@@ -515,7 +515,7 @@ sub PythonFunctionPackIn($$$)
 
 	foreach my $e (@{$fn->{ELEMENTS}}) {
 		next unless (grep(/in/,@{$e->{DIRECTION}}));
-		next if (($metadata_args->{in}->{$e->{NAME}} and grep(/in/, @{$e->{DIRECTION}})) or 
+		next if (($metadata_args->{in}->{$e->{NAME}} and grep(/in/, @{$e->{DIRECTION}})) or
 				 ($metadata_args->{out}->{$e->{NAME}}) and grep(/out/, @{$e->{DIRECTION}}));
 		$self->pidl("PyObject *py_$e->{NAME};");
 		$args_format .= "O";
@@ -739,10 +739,10 @@ sub Interface($$$)
 		$self->pidl("return py_dcerpc_interface_init_helper(type, args, kwargs, &ndr_table_$interface->{NAME});");
 		$self->deindent;
 		$self->pidl("}");
-	
+
 		$self->pidl("");
 
-		my $signature = 
+		my $signature =
 "\"$interface->{NAME}(binding, lp_ctx=None, credentials=None) -> connection\\n\"
 \"\\n\"
 \"binding should be a DCE/RPC binding string (for example: ncacn_ip_tcp:127.0.0.1)\\n\"
@@ -876,7 +876,7 @@ sub import_type_variable($$$)
 sub use_type_variable($$)
 {
 	my ($self, $orig_ctype) = @_;
-	# FIXME: Have a global lookup table for types that look different on the 
+	# FIXME: Have a global lookup table for types that look different on the
 	# wire than they are named in C?
 	if ($orig_ctype->{NAME} eq "dom_sid2" or
 	    $orig_ctype->{NAME} eq "dom_sid28" or
@@ -1020,7 +1020,7 @@ sub ConvertObjectFromPythonData($$$$$$;$)
 		return;
 	}
 
-	if ($actual_ctype->{TYPE} eq "SCALAR" and 
+	if ($actual_ctype->{TYPE} eq "SCALAR" and
 		($actual_ctype->{NAME} eq "string" or $actual_ctype->{NAME} eq "nbt_string" or $actual_ctype->{NAME} eq "nbt_name" or $actual_ctype->{NAME} eq "wrepl_nbt_name")) {
 		$self->pidl("$target = talloc_strdup($mem_ctx, PyString_AS_STRING($cvar));");
 		return;
@@ -1259,8 +1259,8 @@ sub ConvertObjectToPythonData($$$$$;$)
 	my $actual_ctype = $ctype;
 	if ($actual_ctype->{TYPE} eq "TYPEDEF") {
 		$actual_ctype = $actual_ctype->{DATA};
-	} 
-	
+	}
+
 	if ($actual_ctype->{TYPE} eq "ENUM") {
 		return $self->ConvertScalarToPython(Parse::Pidl::Typelist::enum_type_fn($actual_ctype), $cvar);
 	} elsif ($actual_ctype->{TYPE} eq "BITMAP") {
@@ -1412,7 +1412,7 @@ sub Parse($$$$$)
 		($x->{TYPE} eq "IMPORT") && $self->Import(@{$x->{PATHS}});
 	    ($x->{TYPE} eq "INTERFACE") && $self->Interface($x, $basename);
 	}
-	
+
 	$self->pidl("static PyMethodDef $basename\_methods[] = {");
 	$self->indent;
 	foreach (@{$self->{module_methods}}) {
-- 
1.9.1


From ddd1fb32d96a24b97ac52e78114d09e70297a2e0 Mon Sep 17 00:00:00 2001
From: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Date: Wed, 17 Jun 2015 16:08:18 +1200
Subject: [PATCH 3/5] Use large enough unsigned values in server_id IDL

This matches what we have in struct server_id.

Signed-off-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Reviewed-by: Stefan Metzmacher <metze at samba.org>
---
 librpc/idl/server_id.idl | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/librpc/idl/server_id.idl b/librpc/idl/server_id.idl
index 554e428..8ebffc5 100644
--- a/librpc/idl/server_id.idl
+++ b/librpc/idl/server_id.idl
@@ -9,10 +9,10 @@ interface server_id
 	 * Ctdbd sets this, we retrieve our vnn from it.
 	 */
 
-	const int NONCLUSTER_VNN = 0xFFFFFFFF;
+	const uint32 NONCLUSTER_VNN = 0xFFFFFFFF;
 
 	/** Don't verify this unique id */
-	const int SERVERID_UNIQUE_ID_NOT_TO_VERIFY = 0xFFFFFFFFFFFFFFFFULL;
+	const hyper SERVERID_UNIQUE_ID_NOT_TO_VERIFY = 0xFFFFFFFFFFFFFFFFULL;
 
 	/* used to look like the following, note that unique_id was not
 	 * marshalled at all...
-- 
1.9.1


From 1cc2b15ea8b587ce724053ccc8a1a1997bed56b6 Mon Sep 17 00:00:00 2001
From: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Date: Wed, 17 Jun 2015 13:20:29 +1200
Subject: [PATCH 4/5] Avoid casting pointer to unsigned long long for NULL
 check

This allows compilation on i386 with -WError. Otherwise we see
this:

  ../source4/torture/smb2/durable_open.c:41:23: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
       __location__, #v, (unsigned long long)v, (unsigned long long)correct); \

because the pointer is 32 bits, while long long is 64.

Signed-off-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Reviewed-by: Stefan Metzmacher <metze at samba.org>
---
 source4/torture/smb2/durable_open.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/source4/torture/smb2/durable_open.c b/source4/torture/smb2/durable_open.c
index c3d63d1..412455c 100644
--- a/source4/torture/smb2/durable_open.c
+++ b/source4/torture/smb2/durable_open.c
@@ -42,6 +42,13 @@
 		ret = false; \
 	}} while (0)
 
+#define CHECK_NOT_NULL(p) do { \
+	if ((p) == NULL) { \
+		torture_result(tctx, TORTURE_FAIL, "(%s): %s is NULL but it should not be.\n", \
+				__location__, #p); \
+		ret = false; \
+	}} while (0)
+
 #define CHECK_STATUS(status, correct) do { \
 	if (!NT_STATUS_EQUAL(status, correct)) { \
 		torture_result(tctx, TORTURE_FAIL, __location__": Incorrect status %s - should be %s", \
@@ -2267,7 +2274,7 @@ static bool test_durable_open_alloc_size(struct torture_context *tctx,
 
 	/* prepare buffer */
 	b = talloc_zero_size(mem_ctx, alloc_size_step);
-	CHECK_NOT_VAL(b, NULL);
+	CHECK_NOT_NULL(b);
 
 	previous_session_id = smb2cli_session_current_id(tree->session->smbXcli);
 
-- 
1.9.1


From 78a5307346e412f5b81808728bb63d0e9aabf314 Mon Sep 17 00:00:00 2001
From: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Date: Wed, 17 Jun 2015 13:21:28 +1200
Subject: [PATCH 5/5] correct sense of macro variable name in SMB2 durable open
 test

Signed-off-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Reviewed-by: Stefan Metzmacher <metze at samba.org>
---
 source4/torture/smb2/durable_open.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/source4/torture/smb2/durable_open.c b/source4/torture/smb2/durable_open.c
index 412455c..fd6af33 100644
--- a/source4/torture/smb2/durable_open.c
+++ b/source4/torture/smb2/durable_open.c
@@ -35,10 +35,10 @@
 		ret = false; \
 	}} while (0)
 
-#define CHECK_NOT_VAL(v, correct) do { \
-	if ((v) == (correct)) { \
+#define CHECK_NOT_VAL(v, incorrect) do { \
+	if ((v) == (incorrect)) { \
 		torture_result(tctx, TORTURE_FAIL, "(%s): wrong value for %s got 0x%llx - should not be 0x%llx\n", \
-				__location__, #v, (unsigned long long)v, (unsigned long long)correct); \
+				__location__, #v, (unsigned long long)v, (unsigned long long)incorrect); \
 		ret = false; \
 	}} while (0)
 
-- 
1.9.1


More information about the samba-technical mailing list