]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
os/bluestore: do not use nullptr to calc the size of bluestore_pextent_t
authorKefu Chai <kchai@redhat.com>
Sat, 18 Mar 2017 09:07:48 +0000 (17:07 +0800)
committerKefu Chai <kchai@redhat.com>
Sat, 18 Mar 2017 09:08:33 +0000 (17:08 +0800)
see also #13889, otherwise this segfaults when compiled with -O0.

Signed-off-by: Kefu Chai <kchai@redhat.com>
src/os/bluestore/bluestore_types.h

index a385a6acf2bd0c976b16c7ed38418e229c06e82f..57f60afd1f99644b5593b245b81dfab446c84d0c 100644 (file)
@@ -165,9 +165,12 @@ struct denc_traits<PExtentVector> {
   static constexpr bool featured = false;
   static void bound_encode(const PExtentVector& v, size_t& p) {
     p += sizeof(uint32_t);
-    size_t per = 0;
-    denc(*(bluestore_pextent_t*)nullptr, per);
-    p += per * v.size();
+    const auto size = v.size();
+    if (size) {
+      size_t per = 0;
+      denc(v.front(), per);
+      p +=  per * size;
+    }
   }
   static void encode(const PExtentVector& v,
                     bufferlist::contiguous_appender& p) {