1
0
mirror of https://github.com/samba-team/samba.git synced 2025-02-03 13:47:25 +03:00

pidl: Add max property to be used instead of range for unsigned types.

Compilers complain about ranges starting at 0 for unsigned types,
since an unsigned type is never less than 0.  The max property
implicitly makes 0 the lower bound when used with unsigned types.
This commit is contained in:
Tim Prouty 2009-01-15 10:51:57 -08:00
parent 3913d0a205
commit 7c861cac53
3 changed files with 8 additions and 0 deletions

View File

@ -67,6 +67,7 @@ my %supported_properties = (
# array
"range" => ["ELEMENT"],
"max" => ["ELEMENT"],
"size_is" => ["ELEMENT"],
"string" => ["ELEMENT"],
"noheader" => ["ELEMENT"],

View File

@ -921,6 +921,7 @@ my %property_list = (
# array
"range" => ["ELEMENT"],
"max" => ["ELEMENT"],
"size_is" => ["ELEMENT"],
"string" => ["ELEMENT"],
"noheader" => ["ELEMENT"],

View File

@ -862,6 +862,12 @@ sub ParseDataPull($$$$$$$)
$self->pidl("\treturn ndr_pull_error($ndr, NDR_ERR_RANGE, \"value out of range\");");
$self->pidl("}");
}
if (my $max = has_property($e, "max")) {
$var_name = get_value_of($var_name);
$self->pidl("if ($var_name > $max) {");
$self->pidl("\treturn ndr_pull_error($ndr, NDR_ERR_RANGE, \"value out of range\");");
$self->pidl("}");
}
} else {
$self->ParseTypePull($l->{DATA_TYPE}, $ndr, $var_name, $primitives, $deferred);
}