[PATCH] Selftest improvements

jim jim.brown at rsmas.miami.edu
Thu Feb 8 15:18:50 UTC 2018

> On 08/02/18 16:17, jim via samba-technical wrote:
> >/Why do you remove the explicit argument declarations for so many /functions?
> >/These declarations help catch usage errors, i.e. wrong number of calling />/arguments, especially when you add arguments to functions. /
> Hi Jim,
> My understanding is that because these are object methods, the
> prototypes actually were not providing the checking benefits [see
> PERLSUB(1) (section "Prototypes")] -- this is evidenced by the fact that
> some of the prototypes I removed actually had the wrong number of arguments!
> Now that the subroutines are being dynamically called by function
> references, the checking also appears not to apply [see the same source].
> There was also a more concrete reason: the setup code will automatically
> set up multiple environment dependencies and pass each of their vars as
> an individual parameter. Accomplishing this was [seemingly] impossible
> with the prototypes in place.
> Additionally, there seems to be a consensus among perl devs that
> prototypes are generally harmful: see this post (by my colleague) for
> example:http://www.perlmonks.org/?node_id=406231
> If this is okay, attached is a version of the patch with this commit
> separated out and the explanation in the message.
> Thanks,
> - Jamie

You should add explicit run-time checks in each function to verify it 
was called with the expected number of arguments (since the compiler is 
unable to perform these prototype checks). This kind of problem needs to 
be found as early as possible.


More information about the samba-technical mailing list