Bug 57822

Summary: Build fix for YarrParser.h
Product: WebKit Reporter: Balazs Kelemen <kbalazs>
Component: JavaScriptCoreAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: abecsi, barraclough, christoph, msaboff, ossy, pvarga
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: PC   
OS: Linux   
Attachments:
Description Flags
Patch none

Description Balazs Kelemen 2011-04-05 02:08:13 PDT
It does not compile for a long time in my local environment which is: gcc (SUSE Linux) 4.5.0 20100604 [gcc-4_5-branch revision 160292].
Comment 1 Balazs Kelemen 2011-04-05 02:10:52 PDT
Created attachment 88191 [details]
Patch
Comment 2 Csaba Osztrogonác 2011-04-05 02:21:16 PDT
I'm not sure which initialization value should we 
use, ask the Yarr experts, Cpt Stampho and/or Gavin.

*** This bug has been marked as a duplicate of bug 55576 ***
Comment 3 Balazs Kelemen 2011-04-05 02:44:27 PDT
The other bug has not patch and I won't re-upload mine.
0 is seems like a natural value for UChar. Here is some grep output:
Source/JavaScriptCore/runtime/StringPrototype.cpp:865:    UChar ored = 0;
Source/JavaScriptCore/runtime/StringPrototype.cpp:905:    UChar ored = 0;
Source/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp:81:    UChar u = 0;
Comment 4 Csaba Osztrogonác 2011-04-05 03:12:06 PDT
(In reply to comment #3)
> The other bug has not patch and I won't re-upload mine.
Nobody asked you to upload your patch again ...

> 0 is seems like a natural value for UChar. Here is some grep output:
> Source/JavaScriptCore/runtime/StringPrototype.cpp:865:    UChar ored = 0;
> Source/JavaScriptCore/runtime/StringPrototype.cpp:905:    UChar ored = 0;
> Source/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp:81:    UChar u = 0;

It is absolutely useless information. We can't fix the bug without understanding the Yarr parser. I don't know if m_character is used
somewhere before initializing. But using a possibly wrong init value
is so wrong as using an uninitialized value.

Gavin, could you check if this initialization is correct or not?
Comment 5 Csaba Osztrogonác 2011-04-05 03:13:37 PDT
*** Bug 55576 has been marked as a duplicate of this bug. ***
Comment 6 Balazs Kelemen 2011-04-05 04:28:53 PDT
(In reply to comment #4)
> (In reply to comment #3)
> > The other bug has not patch and I won't re-upload mine.
> Nobody asked you to upload your patch again ...
> 
> > 0 is seems like a natural value for UChar. Here is some grep output:
> > Source/JavaScriptCore/runtime/StringPrototype.cpp:865:    UChar ored = 0;
> > Source/JavaScriptCore/runtime/StringPrototype.cpp:905:    UChar ored = 0;
> > Source/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp:81:    UChar u = 0;
> 
> It is absolutely useless information. We can't fix the bug without understanding the Yarr parser. I don't know if m_character is used
> somewhere before initializing.

Don't you think that 0 is better than memory garbage? What else can be the initialization value for an integral type? I don't understand your concerns.
Comment 7 Darin Adler 2011-04-05 09:40:15 PDT
Comment on attachment 88191 [details]
Patch

I think that we don’t want to initialize things just on general principles or because “initialized is better than uninitialized”. It’s best to set the initial value based on an understanding of how the value will be used.
Comment 8 Darin Adler 2011-04-05 09:43:01 PDT
Comment on attachment 88191 [details]
Patch

If we do make this change, it will be just to make the compiler happy. When m_state is Empty it is illegal to look at the character value, so initializing it is only helpful to mitigate programming mistakes. If m_state is set to another state where m_character is used, then m_character will be set appropriately.

The compiler can’t analyze the data flow well enough to see the relationship so it thinks there is a potential problem here, but there is none.
Comment 9 Balazs Kelemen 2011-04-05 14:59:54 PDT
(In reply to comment #8)
> (From update of attachment 88191 [details])
> If we do make this change, it will be just to make the compiler happy. When m_state is Empty it is illegal to look at the character value, so initializing it is only helpful to mitigate programming mistakes. If m_state is set to another state where m_character is used, then m_character will be set appropriately.
> 
> The compiler can’t analyze the data flow well enough to see the relationship so it thinks there is a potential problem here, but there is none.

Sure. The only motivation behind this patch is to make the compiler happy.
Thanks for the review!
Comment 10 Balazs Kelemen 2011-04-05 15:04:52 PDT
Comment on attachment 88191 [details]
Patch

Clearing flags on attachment: 88191

Committed r82988: <http://trac.webkit.org/changeset/82988>
Comment 11 Balazs Kelemen 2011-04-05 15:04:59 PDT
All reviewed patches have been landed.  Closing bug.