Closed
Bug 1267550
Opened 9 years ago
Closed 9 years ago
Rename MOZ_WARN_UNUSED_RESULT as MOZ_MUST_USE
Categories
(Core :: MFBT, defect)
Core
MFBT
Tracking
()
RESOLVED
FIXED
mozilla49
| Tracking | Status | |
|---|---|---|
| firefox49 | --- | fixed |
People
(Reporter: n.nethercote, Assigned: n.nethercote)
References
Details
Attachments
(2 files, 1 obsolete file)
|
9.08 KB,
patch
|
ehsan.akhgari
:
review+
|
Details | Diff | Splinter Review |
|
210.41 KB,
patch
|
froydnj
:
review+
|
Details | Diff | Splinter Review |
MOZ_WARN_UNUSED_RESULT is offputting long. I'm about to add a lot of
these annotations to SpiderMonkey. A shorter synonym would be nice.
| Assignee | ||
Comment 1•9 years ago
|
||
I'm not especially wedded to MOZ_CHECK. Something else equally short would
likely be equally good.
Attachment #8745197 -
Flags: review?(nfroyd)
Comment 2•9 years ago
|
||
In my opinion, MOZ_CHECK is confusingly generic. What are you checking?
Maybe MOZ_USE_RESULT?
Comment 3•9 years ago
|
||
Also if it is good enough to use sometimes, we should probably use it all the time, rather than having multiple names for it sitting around.
Comment 4•9 years ago
|
||
MOZ_MUST_USE ?
Comment 5•9 years ago
|
||
Comment on attachment 8745197 [details] [diff] [review]
Add MOZ_CHECK as a synonym for MOZ_WARN_UNUSED_RESULT
Review of attachment 8745197 [details] [diff] [review]:
-----------------------------------------------------------------
I'm in agreement with mccr8 here; if we're going to use something shorter, we should use it all the time. And MOZ_CHECK doesn't really communicate much (check the return value? check that the provided argument has size less than void*?). I like fitzgen's suggestion; it's a bit more evocative than MOZ_CHECK.
Length comparisons:
MOZ_CHECK
MOZ_MUST_USE
MOZ_MUST_USE_RV ("return value")
MOZ_WARN_UNUSED_RESULT
Though if we're going to get into length comparisons, doing this as a single-argument macro takes more characters (assuming you put the return type and the function name all on one line). ;)
Attachment #8745197 -
Flags: review?(nfroyd)
Comment 6•9 years ago
|
||
Waldo, do you have a favorite color for the bikeshed here?
Flags: needinfo?(jwalden+bmo)
Comment 7•9 years ago
|
||
I got `MOZ_MUST_USE` from Rust's `#[must_use]` attribute, FWIW.
Comment 8•9 years ago
|
||
MOZ_MUST_USE seems cromulent. And yes, no way are we doing the synonym thing. :-)
Flags: needinfo?(jwalden+bmo)
Comment 9•9 years ago
|
||
The name MOZ_MUSE_USE is already used for a type attribute (bug 1180993).
https://mxr.mozilla.org/mozilla-central/ident?i=MOZ_MUST_USE
Comment 10•9 years ago
|
||
(In reply to Jeff Walden [:Waldo] (remove +bmo to email) from comment #8)
> MOZ_MUST_USE seems cromulent. And yes, no way are we doing the synonym
> thing. :-)
(In reply to Nick Fitzgerald [:fitzgen] [⏰PDT; UTC-7] from comment #7)
> I got `MOZ_MUST_USE` from Rust's `#[must_use]` attribute, FWIW.
Let the oxidation of Gecko continue, then.
(In reply to Chris Peterson [:cpeterson] from comment #9)
> The name MOZ_MUSE_USE is already used for a type attribute (bug 1180993).
>
> https://mxr.mozilla.org/mozilla-central/ident?i=MOZ_MUST_USE
r+ on changing that to something else. MOZ_MUST_USE_AS_RETURN_VALUE?
| Assignee | ||
Comment 11•9 years ago
|
||
This will allow MOZ_MUST_USE to be used for a different and more common case.
Attachment #8745665 -
Flags: review?(ehsan)
Comment 12•9 years ago
|
||
Both MOZ_MUST_USE and MOZ_MUST_USE_TYPE are essentially trying to achieve the same goal, but in slightly different ways. Have you considered the alternative of making MOZ_MUST_USE expand to both of these attributes so that we'd use the same identifier for both cases? The only issue is that gcc would warn if warn_unused_result is used on a type, which can be fixed with building with -Wno-attributes.
What do you think, Nick?
Flags: needinfo?(n.nethercote)
| Assignee | ||
Comment 13•9 years ago
|
||
It's an annotation that is used a lot, and should be used even more, so a
shorter name is better.
Attachment #8745843 -
Flags: review?(nfroyd)
| Assignee | ||
Updated•9 years ago
|
Attachment #8745197 -
Attachment is obsolete: true
Flags: needinfo?(n.nethercote)
| Assignee | ||
Comment 14•9 years ago
|
||
(In reply to :Ehsan Akhgari (busy, don't ask for review please) from comment #12)
> Both MOZ_MUST_USE and MOZ_MUST_USE_TYPE are essentially trying to achieve
> the same goal, but in slightly different ways. Have you considered the
> alternative of making MOZ_MUST_USE expand to both of these attributes so
> that we'd use the same identifier for both cases? The only issue is that
> gcc would warn if warn_unused_result is used on a type, which can be fixed
> with building with -Wno-attributes.
>
> What do you think, Nick?
I understand that they have similar goals, but aren't they different mechanisms that can't be used in tandem?
AIUI, MOZ_MUST_USE_TYPE applies to a *type*, and means "any time this type is used as a return value, implicitly add MOZ_MUST_USE to it". Is using MOZ_MUST_USE_TYPE on a function return type even valid?
Flags: needinfo?(ehsan)
Comment 15•9 years ago
|
||
(In reply to Nicholas Nethercote [:njn] from comment #14)
> (In reply to :Ehsan Akhgari (busy, don't ask for review please) from comment
> #12)
> > Both MOZ_MUST_USE and MOZ_MUST_USE_TYPE are essentially trying to achieve
> > the same goal, but in slightly different ways. Have you considered the
> > alternative of making MOZ_MUST_USE expand to both of these attributes so
> > that we'd use the same identifier for both cases? The only issue is that
> > gcc would warn if warn_unused_result is used on a type, which can be fixed
> > with building with -Wno-attributes.
> >
> > What do you think, Nick?
>
> I understand that they have similar goals, but aren't they different
> mechanisms that can't be used in tandem?
Well as things are right now, they are different unrelated mechanisms, but I'm proposing to change that.
> AIUI, MOZ_MUST_USE_TYPE applies to a *type*, and means "any time this type
> is used as a return value, implicitly add MOZ_MUST_USE to it".
Yes.
> Is using
> MOZ_MUST_USE_TYPE on a function return type even valid?
Well, it is valid in that the clang-plugin will just ignore it.
The way that I think about my suggestion is like this: If you put MOZ_MUST_USE on a type, you're requiring that the return values of that type to always be used. If you put it on a function, you're requiring that the return values of just that one function to always be used.
(Note that I'm not advocating for this super-strongly, so if you disagree your current patch is fine too, I just think if we can make people have to remember one fewer thing it's better!)
Flags: needinfo?(ehsan)
| Assignee | ||
Comment 16•9 years ago
|
||
Given that MOZ_MUST_USE_TYPE is rare, and MOZ_MUST_USE is common (and will become more so), I don't conflating them is more likely to cause problems than help.
Comment 17•9 years ago
|
||
Comment on attachment 8745665 [details] [diff] [review]
(part 1) - Rename MOZ_MUST_USE as MOZ_MUST_USE_TYPE
Review of attachment 8745665 [details] [diff] [review]:
-----------------------------------------------------------------
OK, fair enough!
Attachment #8745665 -
Flags: review?(ehsan) → review+
Comment 18•9 years ago
|
||
Comment on attachment 8745843 [details] [diff] [review]
(part 2) - Rename MOZ_WARN_UNUSED_RESULT as MOZ_MUST_USE
Review of attachment 8745843 [details] [diff] [review]:
-----------------------------------------------------------------
Assuming this was done s/MOZ_WARN_UNUSED_RESULT/MOZ_MUST_USE/ or similar, rs=me.
Attachment #8745843 -
Flags: review?(nfroyd) → review+
| Assignee | ||
Comment 19•9 years ago
|
||
> Assuming this was done s/MOZ_WARN_UNUSED_RESULT/MOZ_MUST_USE/ or similar,
> rs=me.
I did it semi-automatically, using Vim macros. If I'd done it automatically I wouldn't have fixed up indentation in multi-line function signatures.
| Assignee | ||
Comment 20•9 years ago
|
||
https://hg.mozilla.org/integration/mozilla-inbound/rev/4fe5cc4663a37c77239fd9f3344d4816fa7c9ce6
Bug 1267550 (part 1) - Rename MOZ_MUST_USE as MOZ_MUST_USE_TYPE. r=ehsan.
https://hg.mozilla.org/integration/mozilla-inbound/rev/3d67e45f994a3ae1ae43479c32c2ed63bbf1a7c8
Bug 1267550 (part 2) - Rename MOZ_WARN_UNUSED_RESULT as MOZ_MUST_USE. r=froydnj.
| Assignee | ||
Updated•9 years ago
|
Summary: Add MOZ_CHECK as a synonym for MOZ_WARN_UNUSED_RESULT → Rename MOZ_WARN_UNUSED_RESULT as MOZ_MUST_USE
Comment 21•9 years ago
|
||
| bugherder | ||
https://hg.mozilla.org/mozilla-central/rev/4fe5cc4663a3
https://hg.mozilla.org/mozilla-central/rev/3d67e45f994a
Status: ASSIGNED → RESOLVED
Closed: 9 years ago
status-firefox49:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla49
You need to log in
before you can comment on or make changes to this bug.
Description
•