if (my $range = has_property($e, "range")) {
$var_name = get_value_of($var_name);
+ my $signed = Parse::Pidl::Typelist::is_signed($l->{DATA_TYPE});
my ($low, $high) = split(/,/, $range, 2);
- $self->pidl("if ($var_name < $low || $var_name > $high) {");
+ if ($low < 0 and not $signed) {
+ warning(0, "$low is invalid for the range of an unsigned type");
+ }
+ if ($low == 0 and not $signed) {
+ $self->pidl("if ($var_name > $high) {");
+ } else {
+ $self->pidl("if ($var_name < $low || $var_name > $high) {");
+ }
$self->pidl("\treturn ndr_pull_error($ndr, NDR_ERR_RANGE, \"value out of range\");");
$self->pidl("}");
}
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(CONST_DISCARD(struct $fn->{NAME} *,r->out.$e->{NAME}), 0, ($size) * sizeof(*r->out.$e->{NAME}));");
+ $self->pidl("memset(r->out.$e->{NAME}, 0, ($size) * sizeof(*r->out.$e->{NAME}));");
}
} else {
$self->pidl("NDR_PULL_ALLOC($ndr, r->out.$e->{NAME});");
sub FunctionCallEntry($$)
{
my ($self, $d) = @_;
- return if not defined($d->{OPNUM});
+ return 0 if not defined($d->{OPNUM});
$self->pidl("\t{");
$self->pidl("\t\t\"$d->{NAME}\",");
$self->pidl("\t\tsizeof(struct $d->{NAME}),");
$self->pidl("\t\t(ndr_print_function_t) ndr_print_$d->{NAME},");
$self->pidl("\t\t".($d->{ASYNC}?"true":"false").",");
$self->pidl("\t},");
+ return 1;
}
#####################################################################
$self->pidl("static const struct ndr_interface_call $interface->{NAME}\_calls[] = {");
foreach my $d (@{$interface->{INHERITED_FUNCTIONS}},@{$interface->{FUNCTIONS}}) {
- $self->FunctionCallEntry($d);
- $count++;
+ $count += $self->FunctionCallEntry($d);
}
$self->pidl("\t{ NULL, 0, NULL, NULL, NULL, false }");
$self->pidl("};");
if (is_intree()) {
$self->pidl("#include \"includes.h\"");
} else {
+ $self->pidl("#ifndef _GNU_SOURCE");
$self->pidl("#define _GNU_SOURCE");
+ $self->pidl("#endif");
$self->pidl("#include <stdint.h>");
$self->pidl("#include <stdlib.h>");
$self->pidl("#include <stdio.h>");