Closed Bug 518881 Opened 15 years ago Closed 15 years ago

IPDL-generated methods should be warn_unused_result

Categories

(Core :: IPC, enhancement)

enhancement
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: cjones, Assigned: cjones)

References

Details

Attachments

(4 files, 1 obsolete file)

Any invocation of them may fail, so client code should always check their return values.
Depends on NS_WARN_UNUSED_RESULT.
Depends on: 441324
No longer depends on: 518880
List of offenders (on linux): /home/cjones/mozilla/mozilla-central/ipc/ipdl/test/cxx/TestLatency.cpp:50: warning: ignoring return value of ‘bool mozilla::_ipdltest::PTestLatencyParent::SendPing()’, declared with attribute warn_unused_result /home/cjones/mozilla/mozilla-central/ipc/ipdl/test/cxx/TestLatency.cpp:60: warning: ignoring return value of ‘bool mozilla::_ipdltest::PTestLatencyParent::SendPing5()’, declared with attribute warn_unused_result /home/cjones/mozilla/mozilla-central/ipc/ipdl/test/cxx/TestLatency.cpp:61: warning: ignoring return value of ‘bool mozilla::_ipdltest::PTestLatencyParent::SendPing5()’, declared with attribute warn_unused_result /home/cjones/mozilla/mozilla-central/ipc/ipdl/test/cxx/TestLatency.cpp:62: warning: ignoring return value of ‘bool mozilla::_ipdltest::PTestLatencyParent::SendPing5()’, declared with attribute warn_unused_result /home/cjones/mozilla/mozilla-central/ipc/ipdl/test/cxx/TestLatency.cpp:63: warning: ignoring return value of ‘bool mozilla::_ipdltest::PTestLatencyParent::SendPing5()’, declared with attribute warn_unused_result /home/cjones/mozilla/mozilla-central/ipc/ipdl/test/cxx/TestLatency.cpp:64: warning: ignoring return value of ‘bool mozilla::_ipdltest::PTestLatencyParent::SendPing5()’, declared with attribute warn_unused_result /home/cjones/mozilla/mozilla-central/ipc/ipdl/test/cxx/TestRacyRPCReplies.cpp:59: warning: ignoring return value of ‘bool mozilla::_ipdltest::PTestRacyRPCRepliesParent::Send_A()’, declared with attribute warn_unused_result /home/cjones/mozilla/mozilla-central/ipc/ipdl/test/cxx/TestRPCRaces.cpp:31: warning: ignoring return value of ‘bool mozilla::_ipdltest::PTestRPCRacesParent::SendStart()’, declared with attribute warn_unused_result /home/cjones/mozilla/mozilla-central/ipc/ipdl/test/cxx/TestShutdown.cpp:11: warning: ignoring return value of ‘bool mozilla::_ipdltest::PTestShutdownParent::SendStart()’, declared with attribute warn_unused_result /home/cjones/mozilla/mozilla-central/dom/plugins/BrowserStreamParent.cpp:87: warning: ignoring return value of ‘bool mozilla::plugins::PBrowserStreamParent::SendNPP_DestroyStream(const NPReason&)’, declared with attribute warn_unused_result /home/cjones/mozilla/mozilla-central/dom/plugins/BrowserStreamParent.cpp:99: warning: ignoring return value of ‘static bool mozilla::plugins::PBrowserStreamParent::Send__delete__(mozilla::plugins::PBrowserStreamParent*)’, declared with attribute warn_unused_result /home/cjones/mozilla/mozilla-central/dom/plugins/BrowserStreamParent.cpp:124: warning: ignoring return value of ‘bool mozilla::plugins::PBrowserStreamParent::SendWrite(const int32_t&, const mozilla::plugins::Buffer&, const uint32_t&)’, declared with attribute warn_unused_result /home/cjones/mozilla/mozilla-central/dom/plugins/BrowserStreamParent.cpp:137: warning: ignoring return value of ‘bool mozilla::plugins::PBrowserStreamParent::CallNPP_StreamAsFile(const nsCString&)’, declared with attribute warn_unused_result /home/cjones/mozilla/mozilla-central/dom/plugins/PluginInstanceParent.cpp:421: warning: ignoring return value of ‘static bool mozilla::plugins::PStreamNotifyParent::Send__delete__(mozilla::plugins::PStreamNotifyParent*, const NPReason&)’, declared with attribute warn_unused_result /home/cjones/mozilla/mozilla-central/dom/plugins/PluginInstanceParent.cpp:756: warning: ignoring return value of ‘static bool mozilla::plugins::PBrowserStreamParent::Send__delete__(mozilla::plugins::PBrowserStreamParent*)’, declared with attribute warn_unused_result /home/cjones/mozilla/mozilla-central/dom/plugins/PluginInstanceParent.cpp:783: warning: ignoring return value of ‘static bool mozilla::plugins::PPluginStreamParent::Call__delete__(mozilla::plugins::PPluginStreamParent*, const NPReason&, const bool&)’, declared with attribute warn_unused_result /home/cjones/mozilla/mozilla-central/dom/plugins/PluginInstanceParent.cpp:877: warning: ignoring return value of ‘static bool mozilla::plugins::PStreamNotifyParent::Send__delete__(mozilla::plugins::PStreamNotifyParent*, const NPReason&)’, declared with attribute warn_unused_result /home/cjones/mozilla/mozilla-central/dom/plugins/PluginScriptableObjectParent.cpp:674: warning: ignoring return value of ‘static bool mozilla::plugins::PPluginScriptableObjectParent::Send__delete__(mozilla::plugins::PPluginScriptableObjectParent*)’, declared with attribute warn_unused_result /home/cjones/mozilla/mozilla-central/dom/plugins/PluginScriptableObjectParent.cpp:694: warning: ignoring return value of ‘bool mozilla::plugins::PPluginScriptableObjectParent::SendUnprotect()’, declared with attribute warn_unused_result /home/cjones/mozilla/mozilla-central/dom/plugins/PluginModuleParent.cpp:394: warning: ignoring return value of ‘static bool mozilla::plugins::PPluginInstanceParent::Call__delete__(mozilla::plugins::PPluginInstanceParent*)’, declared with attribute warn_unused_result I'll fix these with followup patches.
Attachment #439450 - Flags: review?(bent.mozilla)
Oops, I forgot that |(void) foo();| doesn't suppress the unused-result warning. This patch adds a |mozilla::unused()| escape hatch. Verified locally that it optimizes away.
Attachment #439450 - Attachment is obsolete: true
Attachment #439462 - Flags: review?(bent.mozilla)
Attachment #439450 - Flags: review?(bent.mozilla)
bent, please feel free to steal if you wish.
Attachment #439463 - Flags: review?(benjamin)
I should add that I kept the bool return value for child-side methods because I think I layer remoting might want them, in concert with the fatal-error-handling implementation I have in my head. It's easy to change this in the future if my use case doesn't come to fruition.
Comment on attachment 439463 [details] [diff] [review] Fix unused result warnings in dom/plugins This is ok, although I think the unused() function is ugly. Can we avoid the extra parens by using an operator?: unused << SendNPP_DestroyStream(reason);
Attachment #439463 - Flags: review?(benjamin) → review+
Attachment #439462 - Flags: review?(bent.mozilla) → review+
I'm getting this error when trying to build SeaMonkey 2.1a1pre.
I'm pretty sure that this: extern const unused_t unused NS_COM_GLUE; should be something like this: extern const unused_t NS_COM_GLUE unused; Note: I was surprised to find that attachment 439462 [details] [diff] [review] didn't have the unused.h/.cpp additions that got landed in http://hg.mozilla.org/mozilla-central/rev/bd3cfb73386c
Yeah, I was wondering which patch the unused.foo files came from.
(In reply to comment #10) > I'm pretty sure that this: > > extern const unused_t unused NS_COM_GLUE; > > should be something like this: > > extern const unused_t NS_COM_GLUE unused; > Yes, please change it, it failed to compile with Sun Studio.
After checking around on the other uses of NS_COM_GLUE, pushed a bustage fix: http://hg.mozilla.org/mozilla-central/rev/39544b4cb578
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: