summaryrefslogtreecommitdiffstats
path: root/src/test/messenger
diff options
context:
space:
mode:
authorKefu Chai <kchai@redhat.com>2017-05-09 06:52:43 +0200
committerKefu Chai <kchai@redhat.com>2017-05-10 04:31:57 +0200
commitf314bce37467e8fe70c47e8c748480d51dde2196 (patch)
tree0b60d0f85a723fd8ec4acfea405c46afb38578f9 /src/test/messenger
parentcmake: do not link messenger tests against libos (diff)
downloadceph-f314bce37467e8fe70c47e8c748480d51dde2196.tar.xz
ceph-f314bce37467e8fe70c47e8c748480d51dde2196.zip
test/messenger/simple*: throw when fails to malloc
silences the warning of "Null pointer passed as an argument to a 'nonnull' parameter" from clang analyzer. Signed-off-by: Kefu Chai <kchai@redhat.com>
Diffstat (limited to 'src/test/messenger')
-rw-r--r--src/test/messenger/message_helper.h5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/test/messenger/message_helper.h b/src/test/messenger/message_helper.h
index 769c9b4a418..bec2c685cf2 100644
--- a/src/test/messenger/message_helper.h
+++ b/src/test/messenger/message_helper.h
@@ -107,11 +107,12 @@ static inline Message* new_simple_ping_with_data(const char *tag,
for (uint32_t i = 0; i < nfrags; ++i) {
if (do_page_alignment) {
if (posix_memalign(&p, pagesize, segsize))
- p = NULL;
+ p = nullptr;
} else {
p = malloc(segsize);
}
-
+ if (!p)
+ throw std::bad_alloc();
strcpy((char*) p, tag);
uint32_t* t = (uint32_t* ) (((char*) p) + segsize - 32);
*t = counter;