Closed Bug 516298 Opened 15 years ago Closed 15 years ago

TM: fix three compiler warnings

Categories

(Core :: JavaScript Engine, defect)

x86
Linux
defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: n.nethercote, Assigned: n.nethercote)

Details

(Whiteboard: fixed-in-tracemonkey)

Attachments

(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]
patch

Thanks,

/be
(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?

/be
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.

http://hg.mozilla.org/tracemonkey/rev/2fde438e64ff
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.

/be
Follow-up that changes the cast syntax:

http://hg.mozilla.org/tracemonkey/rev/2a3c66f0a36c
http://hg.mozilla.org/mozilla-central/rev/2fde438e64ff
Status: ASSIGNED → RESOLVED
Closed: 15 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.

Attachment

General

Created:
Updated:
Size: