diff options
author | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-05-03 18:41:25 +0000 |
---|---|---|
committer | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-05-03 18:41:25 +0000 |
commit | 24791b60f40b77f44e21ed878e918b897c9bb8f2 (patch) | |
tree | 730f2d2de38a1fd89fb53e19d0d6768f36537414 /base | |
parent | 66c652a9f38913528f6867cebc46141a15396b2f (diff) | |
download | chromium_src-24791b60f40b77f44e21ed878e918b897c9bb8f2.zip chromium_src-24791b60f40b77f44e21ed878e918b897c9bb8f2.tar.gz chromium_src-24791b60f40b77f44e21ed878e918b897c9bb8f2.tar.bz2 |
Add a macro to ignore the return value of a function.
The more typical (void)(function()) does not work with GCC when explicitly marking the -Wunused-value attribute on a function.
I plan to land the fix for bug 42904 in stages:
1) add this macro
2) fix some instance (either a misuse of release(), or just add this macro to it)
3) fix some instance (either a misuse of release(), or just add this macro to it)
....
n - 1) fix some instance (either a misuse of release(), or just add this macro to it)
n) enable the WARN_UNUSED_VALUE attribute on {scoped_ptr,scoped_ptr_malloc,scoped_array}.release()
BUG=42904
TEST=none
Review URL: http://codereview.chromium.org/1794012
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@46252 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r-- | base/basictypes.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/base/basictypes.h b/base/basictypes.h index 1e44303..f6b92ec 100644 --- a/base/basictypes.h +++ b/base/basictypes.h @@ -327,6 +327,17 @@ inline Dest bit_cast(const Source& source) { return dest; } +// Used to explicitly mark the return value of a function as unused. If you are +// really sure you don't want to do anything with the return value of a function +// that has been marked WARN_UNUSED_RESULT, wrap it with this. Example: +// +// scoped_ptr<MyType> my_var = ...; +// if (TakeOwnership(my_var.get()) == SUCCESS) +// IGNORE_RESULT(my_var.release()); +// +#define IGNORE_RESULT(x) \ + do { size_t unused = sizeof(x); unused = 0; } while (false) + // The following enum should be used only as a constructor argument to indicate // that the variable has static storage class, and that the constructor should // do nothing to its state. It indicates to the reader that it is legal to |