Closed Bug 1553567 Opened 7 months ago Closed 7 months ago

Using -1 to initialize nsThread::mCurrentEventLoopDepth is cruel

Categories

(Core :: XPCOM, defect, minor)

defect
Not set
minor

Tracking

()

RESOLVED FIXED
mozilla69
Tracking Status
firefox69 --- fixed

People

(Reporter: jimb, Assigned: jimb)

Details

Attachments

(1 file)

Because nsThread::mCurrentEventLoopDepth exists solely so that we can ask if it's greater than mNestedEventLoopDepth, it is cruel to other programmers to initialize it to -1, because both are uint32_t values, meaning that -1 is greater than any value mNestedEventLoopDepth is likely to take on, not less than such.

The code should instead use UINT32_MAX.

Since the purpose of mCurrentEventLoopDepth is to be ordered in comparison with
mNestedEventLoopDepth, it's a bit deceptive to give it a value that would appear
to be less than any reasonable depth but is, because the variables in question
are unsigned, actually greater than any reasonable depth. Using UINT32_MAX is
clearer.

Assignee: nobody → jimb
Attachment #9066828 - Attachment description: Bug 1553567: Use UINT32_MAX to initialize/reset nsThread::mCurrentEventLoopDepth, not -1. r?froydnj → Bug 1553567: Use MaxValue to initialize/reset nsThread::mCurrentEventLoopDepth, not -1. r?froydnj
Pushed by jblandy@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/44b529f579ea
Use MaxValue to initialize/reset nsThread::mCurrentEventLoopDepth, not -1. r=froydnj
Status: NEW → RESOLVED
Closed: 7 months ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla69
You need to log in before you can comment on or make changes to this bug.