]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: use uint64_t instead of size_t for SparseExtent::length 41239/head
authorKefu Chai <kchai@redhat.com>
Sat, 8 May 2021 13:02:54 +0000 (21:02 +0800)
committerKefu Chai <kchai@redhat.com>
Tue, 11 May 2021 01:31:52 +0000 (09:31 +0800)
SparseBufferlistExtent's ctor accepts size_t, so, on a 32-bit platform,
the parameter would be narrowed before passing to the ctor, and GCC
complains at seeing this:

/builds/a16bitsysop/aports/community/ceph/src/ceph-16.2.3/src/librbd/deep_copy/ObjectCopyRequest.cc:789:60: warning: narrowing conversion of 'object_extent.striper::LightweightObjectExtent::length'
from 'uint64_t' {aka 'long long unsigned int'} to 'size_t' {aka 'unsigned int'} [-Wnarrowing]
  789 |             {io::SPARSE_EXTENT_STATE_ZEROED, object_extent.length});
      |                                              ~~~~~~~~~~~~~~^~~~~~

so change SparseExtent::length to uint64_t, as ReadExtent::length is
uint64_t and related length() methods in the surrounding classes all
return uint64_t.

Signed-off-by: Kefu Chai <kchai@redhat.com>
src/librbd/io/Types.h

index 030f0814a66debb944c981319ea4fc57738c0232..12fea2bb3262ee79b52971f115d4ada227ae037d 100644 (file)
@@ -163,9 +163,9 @@ std::ostream& operator<<(std::ostream& os, SparseExtentState state);
 
 struct SparseExtent {
   SparseExtentState state;
-  size_t length;
+  uint64_t length;
 
-  SparseExtent(SparseExtentState state, size_t length)
+  SparseExtent(SparseExtentState state, uint64_t length)
     : state(state), length(length) {
   }
 
@@ -214,11 +214,11 @@ typedef std::map<WriteReadSnapIds, SparseExtents> SnapshotDelta;
 struct SparseBufferlistExtent : public SparseExtent {
   ceph::bufferlist bl;
 
-  SparseBufferlistExtent(SparseExtentState state, size_t length)
+  SparseBufferlistExtent(SparseExtentState state, uint64_t length)
     : SparseExtent(state, length) {
     ceph_assert(state != SPARSE_EXTENT_STATE_DATA);
   }
-  SparseBufferlistExtent(SparseExtentState state, size_t length,
+  SparseBufferlistExtent(SparseExtentState state, uint64_t length,
                          ceph::bufferlist&& bl_)
     : SparseExtent(state, length), bl(std::move(bl_)) {
     ceph_assert(state != SPARSE_EXTENT_STATE_DATA || length == bl.length());