[PATCH] scripts/test-installation.pl: Handle NSS crypto libraries [BZ #21940]
Florian Weimer
fweimer@redhat.com
Tue Oct 10 09:26:00 GMT 2017
On 10/07/2017 12:50 PM, Rical Jasan wrote:
> I would use:
>
> /^\s*lib(\w+)\.so(?:\.([0-9\.]+))?\s*=>.*\.so(?:\.([0-9\.]+))?/
> ^ ^ ^
> to avoid matching "lib.so.".
I made the change in the attached patch.
>> $found{$name} = 1;
>> - if ($versions{$name} ne $version1 || $version1 ne $version2) {
>> + if (defined($version1) != defined($version2)
>> + || defined($version1) != defined($versions{$name})
>> + || (defined($versions{$name})
>> + && ($versions{$name} ne $version1 || $version1 ne $version2))) {
>> print "Library lib$name is not correctly installed.\n";
>> print "Please check your installation!\n";
>> print "Offending line of ldd output: $_\n";
>
> It might help readability to follow up the match with something like:
>
> next if ! (defined($name) && defined($version1) && defined($version2));
> next if ! (exists $versions{$name}) && defined($versions{$name}));
Is this really clearer? What I wanted to express is âerror if the
defined-ness state is different across the three value, and if
$versions{$name} is defined, it must much both versionsâ. The original
condition captures this fairly succinctly.
> (I seem to recall tests on hash entries creating them when they didn't
> previously exist, but that may not matter here. Something other than
> `next' may also be desirable, and the opportunity for more fine-grained
> error messages is introduced, if useful.)
I suspect the original script was written for Perl 4, which did not have
the exists operator. I instinctively stuck to that baseline.
Anyway, I came up with something simpler, which sidesteps these issues.
> Then you could retain the simpler conditional:
>
> if ($versions{$name} ne $version1 || $version1 ne $version2) {
>
> That also continues using string comparisons, which would be better in
> case there are multiple "."'s.
I only used != as the Boolean XOR operator on the numeric result from
the defined operator.
Thanks,
Florian
-------------- next part --------------
A non-text attachment was scrubbed...
Name: bug21940.patch
Type: text/x-patch
Size: 1687 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/libc-alpha/attachments/20171010/42fd7e6e/attachment.bin>
More information about the Libc-alpha
mailing list