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)
commitaefce8e7c0d82241ab6ecfab7d714338b331bc52
tree05e088050c465d23661387637f8f090c4914619c
parent2765b5c1a27232b990537415718e98449617641b
pidl s4::NDR::Parser: correct has_fast_array logic

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