Bug 40001 - Fix "variable may be used before being set" warning in TextResourceDecoder::checkForHeadCharset
Summary: Fix "variable may be used before being set" warning in TextResourceDecoder::c...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Page Loading (show other bugs)
Version: 528+ (Nightly build)
Hardware: PC All
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-06-01 08:26 PDT by Laszlo Gombos
Modified: 2010-06-02 10:00 PDT (History)
5 users (show)

See Also:


Attachments
proposed patch (1.40 KB, patch)
2010-06-01 08:31 PDT, Laszlo Gombos
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Laszlo Gombos 2010-06-01 08:26:12 PDT
The warning is coming from the RVCT compiler:

"\webkit\WebCore\loader\textresourcedecoder.cpp", line 571: Warning: C2874W: len may be used before being set
        int len;
            ^
Checking the code revealed that this might be a limitation of the compiler as the code is correct and the value of len never read before it gets initialized. I propose to initialize len to 0 just to eliminate the false compiler warning.
Comment 1 Laszlo Gombos 2010-06-01 08:31:51 PDT
Created attachment 57548 [details]
proposed patch
Comment 2 WebKit Commit Bot 2010-06-01 20:03:47 PDT
Comment on attachment 57548 [details]
proposed patch

Clearing flags on attachment: 57548

Committed r60529: <http://trac.webkit.org/changeset/60529>
Comment 3 WebKit Commit Bot 2010-06-01 20:03:52 PDT
All reviewed patches have been landed.  Closing bug.
Comment 4 WebKit Review Bot 2010-06-01 20:44:49 PDT
http://trac.webkit.org/changeset/60529 might have broken GTK Linux 32-bit Release
The following changes are on the blame list:
http://trac.webkit.org/changeset/60528
http://trac.webkit.org/changeset/60529
http://trac.webkit.org/changeset/60530
Comment 5 Darin Adler 2010-06-02 10:00:15 PDT
(In reply to comment #0)
> The warning is coming from the RVCT compiler:
> 
> "\webkit\WebCore\loader\textresourcedecoder.cpp", line 571: Warning: C2874W: len may be used before being set
>         int len;
>             ^
> Checking the code revealed that this might be a limitation of the compiler as the code is correct and the value of len never read before it gets initialized. I propose to initialize len to 0 just to eliminate the false compiler warning.

I'm not sure this is a good precedent. It's OK to change code to sidestep a mistaken warning, but this is the kind of thing that occurs in many places and I don't want to include lots of extra initialization just to quiet the compiler.

Unless you think there's another reason that this kind of code change is good.