[Webkit-unassigned] [Bug 137609] webkitdirs::isCrossCompilation() cause Perl uninitialized warnings when using native GCC toolchain

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Mon Apr 25 21:00:42 PDT 2016


https://bugs.webkit.org/show_bug.cgi?id=137609

Daniel Bates <dbates at webkit.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
 Attachment #239621|review?                     |review+
              Flags|                            |

--- Comment #2 from Daniel Bates <dbates at webkit.org> ---
Comment on attachment 239621
  --> https://bugs.webkit.org/attachment.cgi?id=239621
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=239621&action=review

> Tools/ChangeLog:12
> +        The perl regexp returns an empty array when there is no match (when
> +        the compiler in CC is not configured with --target or --host). Trying
> +        to test the first element of the array will trigger a warning
> +        "Use of uninitialized value $host[0] in string ne". Test that the
> +        array is not empty first.

Maybe a better way to describe the issue is to say:

Fixes an issue where webkitdirs::isCrossCompilation() causes Perl uninitialized warnings when the GCC compiler specified by the environment variable CC was not built for cross compilation.

> Tools/Scripts/webkitdirs.pm:1079
>        my @host = $compiler_options =~ m/--host=(.*?)\s/;
>        my @target = $compiler_options =~ m/--target=(.*?)\s/;
>  
> -      return ($host[0] ne "" && $target[0] ne "" && $host[0] ne $target[0]);
> +      return (@host && @target && $host[0] ne "" && $target[0] ne "" && $host[0] ne $target[0]);

We are underutilizing the use of an array for holding the captured output of the regular expressions because the regular expression on lines 1076 and 1077 each have exactly one capture group. Using the fact that a captured group is always a string and the property that the empty string evaluates to false in a boolean context, I would write this code as:

my $host = $1 if $compiler_options =~ /--host=(.*?)\s/;
my $target = $1 if $compiler_options =~ /--target=(.*?)\s/;
return ($host && $target && $host ne $target);

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.webkit.org/pipermail/webkit-unassigned/attachments/20160426/41cc4108/attachment.html>


More information about the webkit-unassigned mailing list