summaryrefslogtreecommitdiff
path: root/pidl/lib
diff options
context:
space:
mode:
authorTim Prouty <tprouty@samba.org>2009-03-03 13:04:14 -0800
committerTim Prouty <tprouty@samba.org>2009-03-04 18:32:13 -0800
commitcfb47573865610d2e02b08507f09b52c3b38d19e (patch)
tree41bc6888c5747f607c3194eed93e6f8dc0c75b7a /pidl/lib
parent04f5f739056b535c71f0991b388f7f4b14c0b75e (diff)
downloadsamba-cfb47573865610d2e02b08507f09b52c3b38d19e.tar.gz
samba-cfb47573865610d2e02b08507f09b52c3b38d19e.tar.bz2
samba-cfb47573865610d2e02b08507f09b52c3b38d19e.zip
pidl: Don't generate variables declarations for pointless array counters.
Code isn't generated to iterate over arrays of length 0, but the variable declarations still are. The result is 'unused variable' warnings. This only seems to be happening in one place right now, so I targeted the fix to this case, but refactoring could be done to make all variable declarations do this zero length check. Making it the default would be a much more invasive fix. Jelmer, please check!
Diffstat (limited to 'pidl/lib')
-rw-r--r--pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm20
1 files changed, 19 insertions, 1 deletions
diff --git a/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm b/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm
index 34aebc7f0f..7ce9708e14 100644
--- a/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm
+++ b/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm
@@ -1256,7 +1256,7 @@ sub ParseStructPush($$$$)
EnvSubstituteValue($env, $struct);
- $self->DeclareArrayVariables($_) foreach (@{$struct->{ELEMENTS}});
+ $self->DeclareArrayVariablesNoZero($_, $env) foreach (@{$struct->{ELEMENTS}});
$self->start_flags($struct, $ndr);
@@ -1481,6 +1481,24 @@ sub DeclareArrayVariables($$)
}
}
+sub DeclareArrayVariablesNoZero($$$)
+{
+ my ($self,$e,$env) = @_;
+
+ foreach my $l (@{$e->{LEVELS}}) {
+ next if has_fast_array($e,$l);
+ next if is_charset_array($e,$l);
+ if ($l->{TYPE} eq "ARRAY") {
+ my $length = ParseExpr($l->{LENGTH_IS}, $env, $e->{ORIGINAL});
+ if ($length eq "0") {
+ warning($e->{ORIGINAL}, "pointless array cntr: 'cntr_$e->{NAME}_$l->{LEVEL_INDEX}': length=$length");
+ } else {
+ $self->pidl("uint32_t cntr_$e->{NAME}_$l->{LEVEL_INDEX};");
+ }
+ }
+ }
+}
+
sub DeclareMemCtxVariables($$)
{
my ($self,$e) = @_;