pidl: Fix a const build warning in the samba3 merged build
authorTim Prouty <tprouty@samba.org>
Tue, 30 Dec 2008 21:47:58 +0000 (13:47 -0800)
committerTim Prouty <tprouty@samba.org>
Wed, 31 Dec 2008 00:19:43 +0000 (16:19 -0800)
The warning:
../librpc/gen_ndr/ndr_spoolss.c: In function ‘ndr_pull_spoolss_EnumPrinterData’:
../librpc/gen_ndr/ndr_spoolss.c:14792: warning: passing argument 1 of ‘memset’ discards qualifiers from pointer target type

In some case the pidl generated code needs to memset a const struct
field.  This causes the above warning.  This patch discardeds the const
in this case.  I'm open to a more elegant fix, but this eliminates the
warning and should be relatively safe.

pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm

index ee81e51f254bf2dc67cc5f8245ec5486e9275478..5c9123a2a84caaca4bd2a279859c43038b7d5253 100644 (file)
@@ -2165,7 +2165,7 @@ sub ParseFunctionPull($$)
                        if (grep(/in/, @{$e->{DIRECTION}})) {
                                $self->pidl("memcpy(r->out.$e->{NAME}, r->in.$e->{NAME}, ($size) * sizeof(*r->in.$e->{NAME}));");
                        } else {
-                               $self->pidl("memset(r->out.$e->{NAME}, 0, ($size) * sizeof(*r->out.$e->{NAME}));");
+                               $self->pidl("memset(CONST_DISCARD(struct $fn->{NAME} *,r->out.$e->{NAME}), 0, ($size) * sizeof(*r->out.$e->{NAME}));");
                        }
                } else {
                        $self->pidl("NDR_PULL_ALLOC($ndr, r->out.$e->{NAME});");