Bug 48196

Summary: Fix Perl uninitialized warnings in VCSUtils::svnStatus() and VCSUtils::removeEOL().
Product: WebKit Reporter: Daniel Bates <dbates>
Component: Tools / TestsAssignee: Daniel Bates <dbates>
Status: RESOLVED FIXED    
Severity: Normal CC: ddkilzer, mrobinson
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: All   
OS: All   
Attachments:
Description Flags
Patch
none
Patch with unit test
none
Patch with unit test none

Description Daniel Bates 2010-10-23 16:17:03 PDT
VCSUtils::svnStatus() concatenate the output of svn status with new line character. svn status may return no ouput (say for a file that has not been added, deleted, or modified). Currently, VCSUtils::svnStatus() assumes svn status always returns output. Instead, we should check that svn status returns some output before trying to concatenate it with the new line character.

Also, VCSUtils::removeEOL() should return if its argument is uninitialized.
Comment 1 Daniel Bates 2010-10-23 16:26:44 PDT
For completeness, I came across this issues when performing the following within the WebKit directory:

1. Download the patch for bug 6751 <https://bug-6751-attachments.webkit.org/attachment.cgi?id=71377> to ~/Desktop as Bug6751_2.patch

2. WebKitTools/Scripts/svn-apply ~/Desktop/Bug6751_2.patch.

Then the output of svn-apply will contain:
...
patching file LayoutTests/fast/frames/resources/frame-element-name-left.html
patching file LayoutTests/fast/frames/resources/frame-element-name-right.html
Use of uninitialized value $line in substitution (s///) at /Users/dbates/Desktop/WebKit/WebKitTools/Scripts/VCSUtils.pm line 417.
Use of uninitialized value in concatenation (.) or string at /Users/dbates/Desktop/WebKit/WebKitTools/Scripts/VCSUtils.pm line 447.

Notice the uninitialized value warnings.
Comment 2 Daniel Bates 2010-10-23 16:26:59 PDT
Created attachment 71660 [details]
Patch
Comment 3 David Kilzer (:ddkilzer) 2010-10-23 21:41:23 PDT
Comment on attachment 71660 [details]
Patch

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

Is it possible to write a test for this?  Maybe verify that removeEOL(undef) returns ""?

> WebKitTools/Scripts/VCSUtils.pm:416
> +    return unless $line;

Why not do this?

    return "" unless $line;

> WebKitTools/Scripts/VCSUtils.pm:447
> +        $svnStatus = (removeEOL(<SVN>) || "") . "\n";

Then you don't have to do anything special here.
Comment 4 Daniel Bates 2010-10-23 21:46:24 PDT
(In reply to comment #3)
> (From update of attachment 71660 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=71660&action=review
> 
> Is it possible to write a test for this?  Maybe verify that removeEOL(undef) returns ""?

Yes, we can write a test for this. We would need to export the function removeEOL.

> 
> > WebKitTools/Scripts/VCSUtils.pm:416
> > +    return unless $line;
> 
> Why not do this?
> 
>     return "" unless $line;

Will change.
Comment 5 Daniel Bates 2010-10-23 21:57:47 PDT
Created attachment 71668 [details]
Patch with unit test

Updated patch based on David Kilzer's comments. Added unit test.
Comment 6 Daniel Bates 2010-10-23 22:02:28 PDT
Created attachment 71669 [details]
Patch with unit test

Fix copyright in unit test file removeEOL.pl.
Comment 7 David Kilzer (:ddkilzer) 2010-10-24 06:17:57 PDT
Comment on attachment 71669 [details]
Patch with unit test

Thanks Dan!  r=me
Comment 8 Daniel Bates 2010-10-24 09:54:18 PDT
Comment on attachment 71669 [details]
Patch with unit test

Clearing flags on attachment: 71669

Committed r70415: <http://trac.webkit.org/changeset/70415>
Comment 9 Daniel Bates 2010-10-24 09:54:24 PDT
All reviewed patches have been landed.  Closing bug.