[PATCH] Small pidl fix

Andreas Schneider asn at samba.org
Wed Dec 12 21:09:05 UTC 2018


On Wednesday, 12 December 2018 19:38:54 CET Andrew Bartlett wrote:
> On Wed, 2018-12-12 at 19:23 +0100, Andreas Schneider via samba-
> 
> technical wrote:
> > Hi,
> > 
> > the attached patch completes an initializer too avoid build warnings.
> > 
> > 
> > Please review and push if OK.
> 
> Could/should it be changed to a C99 initialiser?

Yes, that seems to work. See attached with two additional fixes ...

-- 
Andreas Schneider                      asn at samba.org
Samba Team                             www.samba.org
GPG-ID:     8DFF53E18F2ABC8D8F3C92237EE0FC4DCC014E3D
-------------- next part --------------
From a260cb60357c503c63278ff8c346cbe80d1e2a05 Mon Sep 17 00:00:00 2001
From: Andreas Schneider <asn at samba.org>
Date: Wed, 12 Dec 2018 19:10:32 +0100
Subject: [PATCH 1/3] pidl: Use C99 initializers for last element in
 ndr_interface_call(_pipes)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

librpc/gen_ndr/ndr_witness.c:1421:2: warning: missing initializer for
field ‘in_pipes’ of ‘const struct ndr_interface_call’
[-Wmissing-field-initializers] <--[gcc]
  { NULL, 0, NULL, NULL, NULL }
  ^

Signed-off-by: Andreas Schneider <asn at samba.org>
---
 pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm b/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm
index cfcd29e25a7..eae58a9a432 100644
--- a/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm
+++ b/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm
@@ -2676,7 +2676,7 @@ sub ParseGeneratePipeArray($$$)
 		$self->deindent;
 		$self->pidl("},");
 	}
-	$self->pidl("{ NULL, NULL, 0, NULL, NULL, NULL }");
+	$self->pidl("{ .name = NULL }");
 	$self->deindent;
 	$self->pidl("};");
 	$self->pidl("");
@@ -2772,7 +2772,7 @@ sub FunctionTable($$)
 	foreach my $d (@{$interface->{INHERITED_FUNCTIONS}},@{$interface->{FUNCTIONS}}) {
 		$count += $self->FunctionCallEntry($d);
 	}
-	$self->pidl("\t{ NULL, 0, NULL, NULL, NULL }");
+	$self->pidl("\t{ .name = NULL }");
 	$self->pidl("};");
 	$self->pidl("");
 
-- 
2.19.2


From 2786437857e61ba15f8c415d0e473031d2c32e30 Mon Sep 17 00:00:00 2001
From: Andreas Schneider <asn at samba.org>
Date: Wed, 12 Dec 2018 20:53:00 +0100
Subject: [PATCH 2/3] pidl: Fix function for py_<name>_ndr_print_(in|out)

The function takes two PyObject arguments, See:

https://docs.python.org/3/c-api/structures.html#c.PyCFunction

and

https://docs.python.org/2/c-api/structures.html#c.PyCFunction

Signed-off-by: Andreas Schneider <asn at samba.org>
---
 pidl/lib/Parse/Pidl/Samba4/Python.pm | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/pidl/lib/Parse/Pidl/Samba4/Python.pm b/pidl/lib/Parse/Pidl/Samba4/Python.pm
index f418ac489ae..01dda41e63d 100644
--- a/pidl/lib/Parse/Pidl/Samba4/Python.pm
+++ b/pidl/lib/Parse/Pidl/Samba4/Python.pm
@@ -817,7 +817,7 @@ sub PythonFunctionStruct($$$$)
 	$self->pidl("}");
 	$self->pidl("");
 
-	$self->pidl("static PyObject *py_$name\_ndr_print_in(PyObject *py_obj)");
+	$self->pidl("static PyObject *py_$name\_ndr_print_in(PyObject *py_obj, PyObject *py_obj2)");
 	$self->pidl("{");
 	$self->indent;
 	$self->pidl("return py_$name\_ndr_print(py_obj, \"$name\_in\", NDR_IN);");
@@ -825,7 +825,7 @@ sub PythonFunctionStruct($$$$)
 	$self->pidl("}");
 	$self->pidl("");
 
-	$self->pidl("static PyObject *py_$name\_ndr_print_out(PyObject *py_obj)");
+	$self->pidl("static PyObject *py_$name\_ndr_print_out(PyObject *py_obj, PyObject *py_obj2)");
 	$self->pidl("{");
 	$self->indent;
 	$self->pidl("return py_$name\_ndr_print(py_obj, \"$name\_out\", NDR_OUT);");
-- 
2.19.2


From 990299f46869c902bf6fb1f0bfe247884ada1f25 Mon Sep 17 00:00:00 2001
From: Andreas Schneider <asn at samba.org>
Date: Wed, 12 Dec 2018 20:58:23 +0100
Subject: [PATCH 3/3] pidl: Fix unsigned integer comparison warning
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

bin/default/librpc/gen_ndr/py_wkssvc.c:27344:33: warning:
comparison of integer expressions of different signedness: ‘long int’
and ‘long long unsigned int’ [-Wsign-compare] <--[gcc]
    if (test_var < 0 || test_var > uint_max) {
                                 ^

Signed-off-by: Andreas Schneider <asn at samba.org>
---
 pidl/lib/Parse/Pidl/Samba4/Python.pm | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pidl/lib/Parse/Pidl/Samba4/Python.pm b/pidl/lib/Parse/Pidl/Samba4/Python.pm
index 01dda41e63d..1ef64db14ee 100644
--- a/pidl/lib/Parse/Pidl/Samba4/Python.pm
+++ b/pidl/lib/Parse/Pidl/Samba4/Python.pm
@@ -1726,7 +1726,7 @@ sub ConvertObjectFromPythonData($$$$$$;$$)
 		$self->indent;
 		$self->pidl("long test_var;");
 		$self->pidl("test_var = PyInt_AsLong($cvar);");
-		$self->pidl("if (test_var < 0 || test_var > uint_max) {");
+		$self->pidl("if (test_var < 0 || (unsigned long long)test_var > uint_max) {");
 		$self->indent;
 		$self->pidl("PyErr_Format(PyExc_OverflowError, \"Expected type %s or %s within range 0 - %llu, got %ld\",\\");
 		$self->pidl("  PyInt_Type.tp_name, PyLong_Type.tp_name, uint_max, test_var);");
-- 
2.19.2



More information about the samba-technical mailing list