Greetings, I just added [1] a new property to XPIDL called [must_use].
When used with an IDL method, it will add MOZ_MUST_USE to the generated C++ declarations and macros relating to that method. Here is an example: /* [must_use] void init (in nsIFile file); */ MOZ_MUST_USE NS_IMETHOD Init(nsIFile *file) = 0; When used with an IDL attribute, it will add MOZ_MUST_USE to the generated C++ getter and setter declarations and macros for that attribute. Here is a getter-only example: /* [must_use] readonly attribute nsIAsyncInputStream inputStream; */ MOZ_MUST_USE NS_IMETHOD GetInputStream(nsIAsyncInputStream * *aInputStream) = 0; Any method or attribute that is fallible and should usually/always have its result checked should use this property. For example, I am working on adding [must_use] to nsIFile.idl [2], and most of the methods and attributes in that file should use this property. (But not all of them; the remove() method is an example where not checking is common and reasonable, because it's usually the last thing done on a file.) I'm only part way through nsIFile.idl and I have already found dozens and dozens of missing checks. Many of these missing checks constitute bugs, and the effects depend on the call site. I am certain that the story will be similar for other IDL files. Therefore, I strongly encourage people to do likewise on any IDL files with which they are familiar. Adding appropriate checks isn't always easy, so it's nice if it can be done by people familiar with the code in question. More generally, we stand to benefit from wider use of MOZ_MUST_USE in normal C++ code, too. Any function that returns an error indicator (usually nsresult or bool) is a good candidate. Past experience has shown that the use of MOZ_MUST_USE frequently turns up missing checks. If you file a bug to add [must_use] or MOZ_MUST_USE somewhere, please make the bug block the tracking bug [3]. I'm happy to answer any questions people might have about this topic. Nick [1] https://bugzilla.mozilla.org/show_bug.cgi?id=1295825 [2] https://bugzilla.mozilla.org/show_bug.cgi?id=1296164 [3] https://bugzilla.mozilla.org/show_bug.cgi?id=MOZ_MUST_USE _______________________________________________ dev-platform mailing list dev-platform@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-platform