--On Tuesday, September 24, 2002 1:25 PM -0700 Jim Trocki
<[EMAIL PROTECTED]> wrote:
> yeah, well -w carps on this:
>
> my %h;
>
> die if ($h{"stuff"} ne "" );
>
> there's nothing wrong with that code, imo. however, to make -w happy,
> you have to re-write it like this:
>
> my %h;
>
> if (exists $h{"stuff"})
> {
> die if ($h{"stuff"} ne "" );
> }
>
> doesn't seem like it's worthwhile, just to make -w happy.
>
Actually, that doesn't necessarily make -w happy. Add "$h{stuff} =
undef;" before the if and you'll see that.
I think the right way to write the test is:
die if (defined $h{stuff} and $h{stuff} ne "");
> i do agree that in some cases this particular carp may point out some
> actual coding mistakes. when you made these changes, did you happen
> to find any bugs because of -w?
Actually, I think I did. Theres a really subtle bug in the trap
authentication code that I think perl -w tipped me off on. In particular,
the code was doing:
if (defined ($AUTHTRAPS{$traphost}{"*"}))
{
$trapuser = "*";
$trappass = "";
}
else
{
$trapuser = $trap{"usr"};
$trappass = $trap{"pas"};
}
if (!defined ($AUTHTRAPS{$traphost}))
{
syslog ('err', "received trap from unauthorized host: $fromip");
return undef;
}
The problem is that in the first if $AUTHTRAPS{$traphost} was springing
into existance via autovivification, and thus the second if was never
triggering. By reordering the tests it started working right. I don't
think perl -w was complaining about this specifically, but something right
around there. And I was looking for a bug with trap authentication anyway,
as I knew traps from a host not listed in the auth.cf were still being
accepted.
I'm going to be sending you another large patchset today. Do you want the
attached documentation to be as verbose as the last one?
-David Nolan
Network Software Developer
Computing Services
Carnegie Mellon University
_______________________________________________
mon mailing list
[EMAIL PROTECTED]
http://linux.kernel.org/mailman/listinfo/mon