<html>
    <head>
      <base href="https://bugs.webkit.org/" />
    </head>
    <body><span class="vcard"><a class="email" href="mailto:dbates&#64;webkit.org" title="Daniel Bates &lt;dbates&#64;webkit.org&gt;"> <span class="fn">Daniel Bates</span></a>
</span> changed
              <a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - webkitdirs::isCrossCompilation() cause Perl uninitialized warnings when using native GCC toolchain"
   href="https://bugs.webkit.org/show_bug.cgi?id=137609">bug 137609</a>
        <br>
             <table border="1" cellspacing="0" cellpadding="8">
          <tr>
            <th>What</th>
            <th>Removed</th>
            <th>Added</th>
          </tr>

         <tr>
           <td style="text-align:right;">Attachment #239621 Flags</td>
           <td>review?
           </td>
           <td>review+
           </td>
         </tr></table>
      <p>
        <div>
            <b><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - webkitdirs::isCrossCompilation() cause Perl uninitialized warnings when using native GCC toolchain"
   href="https://bugs.webkit.org/show_bug.cgi?id=137609#c2">Comment # 2</a>
              on <a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - webkitdirs::isCrossCompilation() cause Perl uninitialized warnings when using native GCC toolchain"
   href="https://bugs.webkit.org/show_bug.cgi?id=137609">bug 137609</a>
              from <span class="vcard"><a class="email" href="mailto:dbates&#64;webkit.org" title="Daniel Bates &lt;dbates&#64;webkit.org&gt;"> <span class="fn">Daniel Bates</span></a>
</span></b>
        <pre>Comment on <span class=""><a href="attachment.cgi?id=239621&amp;action=diff" name="attach_239621" title="Patch">attachment 239621</a> <a href="attachment.cgi?id=239621&amp;action=edit" title="Patch">[details]</a></span>
Patch

View in context: <a href="https://bugs.webkit.org/attachment.cgi?id=239621&amp;action=review">https://bugs.webkit.org/attachment.cgi?id=239621&amp;action=review</a>

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

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.

<span class="quote">&gt; Tools/Scripts/webkitdirs.pm:1079
&gt;        my &#64;host = $compiler_options =~ m/--host=(.*?)\s/;
&gt;        my &#64;target = $compiler_options =~ m/--target=(.*?)\s/;
&gt;  
&gt; -      return ($host[0] ne &quot;&quot; &amp;&amp; $target[0] ne &quot;&quot; &amp;&amp; $host[0] ne $target[0]);
&gt; +      return (&#64;host &amp;&amp; &#64;target &amp;&amp; $host[0] ne &quot;&quot; &amp;&amp; $target[0] ne &quot;&quot; &amp;&amp; $host[0] ne $target[0]);</span >

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 &amp;&amp; $target &amp;&amp; $host ne $target);</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are the assignee for the bug.</li>
      </ul>
    </body>
</html>