1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-10 01:18:15 +03:00

pidl:Samba3/ClientNDR: $size can be 'foo / 2' so we need to add '(' and ')'

foo / 5 * sizeof(bar)' isn't the same as
'(foo / 2) * sizeof(bar)'.

metze
This commit is contained in:
Stefan Metzmacher 2009-11-25 14:31:34 +01:00
parent ab1c92950f
commit a20e095b1f
2 changed files with 3 additions and 3 deletions

View File

@ -105,9 +105,9 @@ sub ParseOutputArgument($$$;$$)
} else {
my $size_is = ParseExpr($l->{SIZE_IS}, $env, $e->{ORIGINAL});
if (has_property($e, "charset")) {
$self->pidl("memcpy(CONST_DISCARD(char *, $o$e->{NAME}), ${r}out.$e->{NAME}, $size_is * sizeof(*$o$e->{NAME}));");
$self->pidl("memcpy(discard_const_p(uint8_t, $o$e->{NAME}), ${r}out.$e->{NAME}, ($size_is) * sizeof(*$o$e->{NAME}));");
} else {
$self->pidl("memcpy($o$e->{NAME}, ${r}out.$e->{NAME}, $size_is * sizeof(*$o$e->{NAME}));");
$self->pidl("memcpy($o$e->{NAME}, ${r}out.$e->{NAME}, ($size_is) * sizeof(*$o$e->{NAME}));");
}
}
} else {

View File

@ -301,4 +301,4 @@ my $e = { NAME => "foo", ORIGINAL => { FILE => "f", LINE => -1 },
LEVELS => [ { TYPE => "ARRAY", SIZE_IS => "mysize" }, { TYPE => "DATA", DATA_TYPE => "int" } ]};
$x->ParseOutputArgument($fn, $e);
is($x->{res}, "memcpy(foo, r.out.foo, mysize * sizeof(*foo));\n");
is($x->{res}, "memcpy(foo, r.out.foo, (mysize) * sizeof(*foo));\n");