On Fri, Apr 29, 2016 at 10:25 AM, Nicholas Nethercote
<n.netherc...@gmail.com> wrote:
>
> I just landed on inbound the patches in bug 1267550, which renamed
> MOZ_WARN_UNUSED_RESULT as MOZ_MUST_USE.
>
> A shorter name was in order because it's an attribute that is already
> used widely, and should be used even more, because it catches real
> problems. In fact, any function that is fallible and returns a
> non-pointer value (usually a bool or nsresult) is a candidate for a
> MOZ_MUST_USE annotation.

I've created bug 1268766 as a meta-bug for tracking the addition of
more uses of MOZ_MUST_USE. I've started working on this in a few
places -- and already found a bunch of missing failure checks -- but
we have more than enough code for the task to be shared around, if
anybody is interested.

Also note that we have another attribute called MOZ_MUST_USE_TYPE,
which can be applied to a type, and then any function that returns
that type will need to be checked. (In other words, it implicitly adds
MOZ_MUST_USE to any function that returns that type.) Bug 1209780 is a
nice example of its use. (Note that it used to be called MOZ_MUST_USE,
and was renamed MOZ_MUST_USE_TYPE to allow MOZ_WARN_UNUSED_RESULT to
be renamed as MOZ_MUST_USE.) However, it only works in static analysis
builds, whereas MOZ_MUST_USE also works in GCC and clang, so although
it clutters up code less, it also results in less immediate error
messages.

Nick
_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform

Reply via email to