Re: pactester perl script bug fix

12 views
Skip to first unread message

Manu Garg

unread,
Apr 23, 2007, 3:36:21 PM4/23/07
to Glenn Zazulia, pact...@googlegroups.com
[+pact...@googlegroups.com]

Thanks a lot Glenn for catching this! Really appreciate it.

Changes pushed to SVN repository. I'll be releasing new version shortly.

Cheers,
-Manu

P.S. This reminds me the need of unittests for pactester. I'll soon be
working on that.

On 4/23/07, Glenn Zazulia <pact...@g.zazu.com> wrote:
> Hi,
>
> Thanks for making available the pactester tool. It's a useful test
> tool. While using it, I noticed that there is a bug with the dnsResolve
> subroutine -- at least it runs incorrectly on my Fedora FC6 system (perl
> 5.8.8). I haven't played with perl subroutine prototypes much, but
> there seems to be an issue with the way you declare dns_res($) and the
> way you call it in dnsResolve (@_). Your declaration expects a single
> scalar parameter, but you call it with a list. Even if the list might
> contain only a single scalar element during runtime, the prototypes are
> a compile-time feature. One might have expected the perl compiler to
> flag the call signature mismatch, but instead, it silently converts the
> list context to scalar context, just as it would do with the following
> statement: $nitems = @item_list. In other words, the $hostname
> variable in dns_res() ends up containing the value "1" (ie. the count of
> list elements) instead of the actual first element of the original list
> (ie. the hostname). If you remove the prototype declaration from
> dns_res, it runs properly. Alternatively, if you keep the prototype
> declaration but change the calling statement in dnsResolve from "dns_res
> @_" to "dns_res shift", it runs properly.
>
> Similarly, you have a mismatch and improper prototype declaration for
> myip / myIpAddress, though in this case it works fine since no actual
> parameter is processed, even though the declaration states that one is
> expected ($). Here, you should either remove the prototype and just use
> "sub myip" or else if you really like using perl sub prototypes, then
> change that line to the correct form specifying a prototype that expects
> no parameters: "sub myip()". You should also remove the "@_" parameter
> from the myip call in myIpAddress, since this subroutine shouldn't be
> passed any parameters.
>
> Otherwise, it's a great tool. Thanks again for it.
>
> Glenn Zazulia
>


--
Manu Garg
http://www.manugarg.com
"Journey is the destination of life."

Reply all
Reply to author
Forward
0 new messages