TM: fix three compiler warnings

RESOLVED FIXED

Status

()

Core
JavaScript Engine
RESOLVED FIXED
9 years ago
7 years ago

People

(Reporter: njn, Assigned: njn)

Tracking

Trunk
x86
Linux
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(Whiteboard: fixed-in-tracemonkey)

Attachments

(1 attachment)

(Assignee)

Description

9 years ago
Created attachment 400401 [details] [diff] [review]
patch

../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...)
(Assignee)

Comment 3

9 years ago
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
(Assignee)

Comment 5

9 years ago
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
(Assignee)

Comment 7

9 years ago
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
Last Resolved: 9 years ago
Resolution: --- → FIXED

Updated

9 years ago
Flags: wanted1.9.2?

Updated

7 years ago
Flags: wanted1.9.2?
You need to log in before you can comment on or make changes to this bug.