[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Bug#513663: [general] need infrastructure to check related packages



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

On 2011-01-10 11:54, Adam D. Barratt wrote:
> On Mon, January 10, 2011 09:51, Niels Thykier wrote:
>> Alright, I need a second pair of eyes here.  In frontend/lintian there
>> is a piece of code[1].  This is about line 880ish in the infra-513663
>> branch.
>>
>> I am almost certain there is something fishy going on within the if
>> body.  With a bit of "printf"-debugging I have concluded that $checks in
>> "if ($check_tags) {" part is A) a scalar and B) undefined yet it is
>> happily used as a hash!
> 
> Nope, this is a case of confusingly overloaded variable names.  We have
> 
>   my $action;
>   my $checks;
>   my $check_tags;
>   [...]
>   my %collection_info;
>   my %checks;
>   my %check_abbrev;
> 
> $checks is a scalar populated by --{dont-,}check-part, %checks is a hash
> indicating which scripts from checks/ should be run. So $checks is the
> former, $checks{foo} is an index in to the latter.
> 
> $check_tags and $checks are mutually exclusive, so on entry to that
> section of code, $checks will indeed be undefined and %checks will be an
> empty hash which is then populated by the foreach.
> 
>>   The else-part looks just as fishy!  It split $checks on /,/ (so it is
>> used as a scalar again), yet it also happily uses $checks as a hash just
>> a bit further down.
> 
> Same again.  It splits $checks and then populates %checks.
> 
>> I am guessing that these $checks{...} maps should have been replaced by
>> (something like) $check_info{...}->{'requested-tags'}.  But I would like
>> this confirmed.
> 
> %checks is a list of script names, not a list of tags, so I'm not sure I
> follow here (although I may just need more coffee).
> 
> Regards,
> 
> Adam
> 
> 

Thanks for the clarification!

The code makes a lot more sense after "discovering" the %checks
hash.  I have taken the liberty to rename the hash to %enabled_checks in
the code in the branch.  Even if Perl can handle the original code, I
think the variable overloading makes it harder for programmers to review
the code.

~Niels

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQIcBAEBCAAGBQJNK2+WAAoJEAVLu599gGRCJCMP/AhZbzgVZYDuWlaia6h9HqFb
JYpXCJ4C+ixPZ2dB4fLv+25AVsbEdrUInVO7o5Up3bXe6w8YY155Q7hVtzQZ5/5x
9HtBPAA6XE4ofsbPXEKwNcMp+y0r3mg9ncaAf7auGxofjJdT2CMc41j+NiRWwC6e
qj9dPxp7usXCapo+IIpuGDh1sjH7nV5Qv9g8b8aVn3WZpOkUWGEzEbJh2VFqsl3h
OHracDmEMC+PZkQ0XawH2Voz5s2bWfOQa1MTD2ZhZCIhdJiz4VUEq/A200YCpH8i
b6827lS+yL87QnS0DrYnVQFvEVDMM9VvvnJUcPdCPqMFu5qAVzSKh5/DUlE71Jly
lYCwtRFGk+XhdgwYSAyMOd5u1vEhuGfAUBEmE5ylzOrtwkIYVr7P+A5fyXA+SqTy
HWKeiUr7ydMQAUYJ1sEbmuTXUhxgQdSRYREP7o7aZZwEHw8Nb6wQYMMaqtFy96X+
mdi/03PDHHlwe9IVy4jNzFjax/5vnVqBXEm2rHPDrkWWUgpILWfLutiWfPKwcd8U
34Y5k/biBRoiIfAtvvr3BGK9fN4EWeNzAClvOVwyztsggYH1BbvDmixWBGJqhP8Q
461xXrZ0+EMchwXluRfn3hfG3HtvBFXyro3hGXqpBhV6+1Tm9Cx70sBYBv/IN9JE
NULz1GCEc8MVhywH1G06
=zIhn
-----END PGP SIGNATURE-----


Reply to: