Closed Bug 516298 Opened 10 years ago Closed 10 years ago

TM: fix three compiler warnings


(Core :: JavaScript Engine, defect)

Not set





(Reporter: njn, Assigned: njn)


(Whiteboard: fixed-in-tracemonkey)


(1 file)

Attached patch patchSplinter Review
../jsfun.cpp: In member function ‘int JSFunction::sharpSlotBase(JSContext*)’:
../jsfun.cpp:1802: warning: ‘index’ may be used uninitialised in this function

This one seems reasonable -- js_LookupLocal isn't guaranteed to initialise 'i' (hopefully it always does due to some jstracer-specific invariant that GCC doesn't know about).  Using -1 as default seems reasonable since that's sharpSlotBase()'s default return value.

../jsnum.cpp:1347: warning: ‘bdr.BinaryDigitReader::digit’ may be used uninitialised in this function

Seems like GetNextBinaryDigit() will always initialize 'digit', given the other values in 'bdr'.  I used 0 as the default initialization value, seems the most obvious (and should 'digit' truly fail to be initialized, 0 will be correct half the time :)

../jsregexp.cpp:2009: warning: ‘core’ defined but not used

Removed this variable.
Attachment #400401 - Flags: review?(brendan)
Attachment #400401 - Flags: review?(brendan) → review+
Comment on attachment 400401 [details] [diff] [review]


(I hope no compiler warns about initializing unsigned types with -1...)
Good point -- you want me to change it to zero?
No,the caller (js_Execute) will defend given -1. At most we want uintN(-1) sa the initializer, but I'm not sure you will get a warning with -1. Try it and see?

I didn't get a warning with the naked -1, but I thought other compilers might warn, and the (uintN) cast is useful documentation, so I included the cast.
Whiteboard: fixed-in-tracemonkey
Prefer C++ style casts now (uintN(-1) as I wrote in comment 4, not (uintN)-1). Nit for sure, but rs=me on followup change.

I don't see the cast as documentation in any event. The variable's type is the same, and nothing is in a comment, so it's just redundancy.

Follow-up that changes the cast syntax:
Closed: 10 years ago
Resolution: --- → FIXED
Flags: wanted1.9.2?
Flags: wanted1.9.2?
You need to log in before you can comment on or make changes to this bug.