summaryrefslogtreecommitdiff
path: root/pidl/lib/Parse/Pidl/Samba4/NDR
diff options
context:
space:
mode:
authorTim Prouty <tprouty@samba.org>2009-01-17 14:40:12 -0800
committerTim Prouty <tprouty@samba.org>2009-01-17 19:37:52 -0800
commit142b2a61f8a77b3065ce4c78b459ab714d6d190a (patch)
tree6215d9521f1d4fb97a0b88b2e3561811a8420d50 /pidl/lib/Parse/Pidl/Samba4/NDR
parent6d300399b52e0921ce205ef2f053b722b21edeeb (diff)
downloadsamba-142b2a61f8a77b3065ce4c78b459ab714d6d190a.tar.gz
samba-142b2a61f8a77b3065ce4c78b459ab714d6d190a.tar.bz2
samba-142b2a61f8a77b3065ce4c78b459ab714d6d190a.zip
pidl: Remove "max" and make "range" smarter about unsigned types
This eliminates a warning in pidl generated code, while preserving cross-platform idl compatibility.
Diffstat (limited to 'pidl/lib/Parse/Pidl/Samba4/NDR')
-rw-r--r--pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm16
1 files changed, 9 insertions, 7 deletions
diff --git a/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm b/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm
index e2b14c10b1..44d21f0b4a 100644
--- a/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm
+++ b/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm
@@ -857,14 +857,16 @@ sub ParseDataPull($$$$$$$)
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) {");
- $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) {");
+ 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("}");
}