]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
test/messenger/simple*: throw when fails to malloc
authorKefu Chai <kchai@redhat.com>
Tue, 9 May 2017 04:52:43 +0000 (12:52 +0800)
committerKefu Chai <kchai@redhat.com>
Wed, 10 May 2017 02:31:57 +0000 (10:31 +0800)
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>
src/test/messenger/message_helper.h

index 769c9b4a4187256ed5404bc2452c0263229fa664..bec2c685cf206db3c8ebcdd520c93f02750b5b39 100644 (file)
@@ -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;