summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortc@google.com <tc@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-24 21:22:33 +0000
committertc@google.com <tc@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-24 21:22:33 +0000
commit1e86aa6ec38166adb003fc6359c0fe85f63a71c9 (patch)
tree303c4af9f350ff1bb664db512e94f5e6a0cb2824
parent63c2ba2fbc2d1aa1516a6c023d111ab86f0f4acc (diff)
downloadchromium_src-1e86aa6ec38166adb003fc6359c0fe85f63a71c9.zip
chromium_src-1e86aa6ec38166adb003fc6359c0fe85f63a71c9.tar.gz
chromium_src-1e86aa6ec38166adb003fc6359c0fe85f63a71c9.tar.bz2
Add a gcc warning if we don't check the results of ReadParam. Some
of the buildbots noticed that we weren't checking the results when generating log output. AGL gets the credit for tracking this down. Review URL: http://codereview.chromium.org/93126 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@14475 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/extensions/extension_messages_unittest.cc4
-rw-r--r--chrome/common/ipc_message_utils.h11
2 files changed, 8 insertions, 7 deletions
diff --git a/chrome/browser/extensions/extension_messages_unittest.cc b/chrome/browser/extensions/extension_messages_unittest.cc
index 009d574..8f830dd 100644
--- a/chrome/browser/extensions/extension_messages_unittest.cc
+++ b/chrome/browser/extensions/extension_messages_unittest.cc
@@ -47,7 +47,7 @@ TEST_F(RenderViewTest, ExtensionMessagesOpenChannel) {
ASSERT_TRUE(alert_msg);
void* iter = IPC::SyncMessage::GetDataIterator(alert_msg);
ViewHostMsg_RunJavaScriptMessage::SendParam alert_param;
- IPC::ReadParam(alert_msg, &iter, &alert_param);
+ ASSERT_TRUE(IPC::ReadParam(alert_msg, &iter, &alert_param));
EXPECT_EQ(L"content got: 42", alert_param.a);
}
@@ -90,6 +90,6 @@ TEST_F(RenderViewTest, ExtensionMessagesOnConnect) {
ASSERT_TRUE(alert_msg);
void* iter = IPC::SyncMessage::GetDataIterator(alert_msg);
ViewHostMsg_RunJavaScriptMessage::SendParam alert_param;
- IPC::ReadParam(alert_msg, &iter, &alert_param);
+ ASSERT_TRUE(IPC::ReadParam(alert_msg, &iter, &alert_param));
EXPECT_EQ(L"got: 42", alert_param.a);
}
diff --git a/chrome/common/ipc_message_utils.h b/chrome/common/ipc_message_utils.h
index 8e4e8a5..3438e52 100644
--- a/chrome/common/ipc_message_utils.h
+++ b/chrome/common/ipc_message_utils.h
@@ -121,7 +121,8 @@ static inline void WriteParam(Message* m, const P& p) {
}
template <class P>
-static inline bool ReadParam(const Message* m, void** iter, P* p) {
+static inline bool WARN_UNUSED_RESULT ReadParam(const Message* m, void** iter,
+ P* p) {
return ParamTraits<P>::Read(m, iter, p);
}
@@ -1267,8 +1268,8 @@ class MessageWithReply : public SyncMessage {
if (msg->is_sync()) {
SendParam p;
void* iter = SyncMessage::GetDataIterator(msg);
- ReadParam(msg, &iter, &p);
- LogParam(p, l);
+ if (ReadParam(msg, &iter, &p))
+ LogParam(p, l);
#if defined(IPC_MESSAGE_LOG_ENABLED)
const std::wstring& output_params = msg->output_params();
@@ -1282,8 +1283,8 @@ class MessageWithReply : public SyncMessage {
// can finally log the message.
typename ReplyParam::ValueTuple p;
void* iter = SyncMessage::GetDataIterator(msg);
- ReadParam(msg, &iter, &p);
- LogParam(p, l);
+ if (ReadParam(msg, &iter, &p))
+ LogParam(p, l);
}
}