Open Bug 1682214 Opened 5 years ago Updated 5 years ago

nsDeque::ObjectAt's NS_WARN_IF is noisy, yet not informative enough, reconsider API

Categories

(Core :: XPCOM, enhancement)

enhancement

Tracking

()

People

(Reporter: mozbugz, Unassigned)

Details

While running local builds, in the terminal I I see lots of lines like this:

[Child 90668, MediaSupervisor #2] WARNING: 'aIndex >= GetSize()', file c:/mozilla-source/obj-mc-dbg/dist/include\nsDeque.h:360

I think this warning is not very helpful:

  • It doesn't show the source of the call.
  • It's giving confusing messages: It warns about exceeding the deque size (so it's a bad thing?), but still returns a nullptr (so it's ok if I test it?)

In my opinion, it would be better to split this API, so that we don't get warnings when the caller does the right thing, and so that it really crashes hard otherwise, to quickly catch and expose misuses.

For example, we could have:

  • NotNull<T*> ObjectAt() with at least a MOZ_DIAGNOSTIC_ASSERT(); or it could return a reference.
  • T* GetObjectAt(), the "Get" prefix is the traditional way to indicate that the function may return null.
    There are not that many callers, so I think it would be a reasonably-sized task to change the API and update all callers as needed.
You need to log in before you can comment on or make changes to this bug.