]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
pidl s4::NDR::Parser: correct has_fast_array logic
authorDouglas Bagnall <douglas.bagnall@catalyst.net.nz>
Sat, 30 Nov 2019 09:52:23 +0000 (22:52 +1300)
committerAndrew Bartlett <abartlet@samba.org>
Tue, 10 Dec 2019 02:53:35 +0000 (02:53 +0000)
Here we fix two bugs that cancelled each other out completely, so this
patch leaves us with exactly the same functionally as before.

Bug 1: In perl, return is *syntactically* a function.

That means 'return X or Y' is read as 'return(X) or Y', as in the
'open(X) or die "..."' construct -- Y is only evaluated if return
returns false. But return never returns, so Y is dead code. If in
doubt, try these:

perl -e "sub x {return 0 or die;} x"
perl -e "sub x {return (0 or die);} x"

What we *meant* here is 'return (X or Y)', BUT it turns out we were
confused -- the Y case was bogus.

Bug 2: string arrays never had "fast array logic" in the first place.

The fast array logic is for arrays of bytes, and can be fast (i.e.
memcpy) because there is no endianness to worry about. A string array
is an array of pointers not bytes.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm

index 276588351a2fa5202ac395e97fe4855c584827ab..0ea7a683d95cca5ddae17c926a1bb4b6e26591a2 100644 (file)
@@ -84,8 +84,8 @@ sub has_fast_array($$)
 
        my $t = getType($nl->{DATA_TYPE});
 
-       # Only uint8 and string have fast array functions at the moment
-       return ($t->{NAME} eq "uint8") or ($t->{NAME} eq "string");
+       # Only uint8 has a fast array function at the moment
+       return ($t->{NAME} eq "uint8");
 }