submitted as https://github.com/ceph/ceph/pull/41239 commit 558adef26a2149b0dd644a2c9a7e2db8d370b556 Author: Kefu Chai Date: Sat May 8 21:02:54 2021 +0800 librbd/deep_copy: cast uint64_t to size_t for constructing SparseBufferlistExtent 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}); | ~~~~~~~~~~~~~~^~~~~~ this change make this cast explicit and silences the warning. Signed-off-by: Kefu Chai diff --git a/src/librbd/deep_copy/ObjectCopyRequest.cc b/src/librbd/deep_copy/ObjectCopyRequest.cc index e86ed5ea1c..efc6749536 100644 --- a/src/librbd/deep_copy/ObjectCopyRequest.cc +++ b/src/librbd/deep_copy/ObjectCopyRequest.cc @@ -614,7 +614,8 @@ void ObjectCopyRequest::merge_write_ops() { m_snapshot_sparse_bufferlist[src_snap_seq].insert( object_extent.offset, object_extent.length, - {io::SPARSE_EXTENT_STATE_DATA, object_extent.length,\ + {io::SPARSE_EXTENT_STATE_DATA, + static_cast(object_extent.length), std::move(sub_bl)}); buffer_offset += object_extent.length; diff --git a/src/librbd/io/CopyupRequest.cc b/src/librbd/io/CopyupRequest.cc index d70851409f..a3af713151 100644 --- a/src/librbd/io/CopyupRequest.cc +++ b/src/librbd/io/CopyupRequest.cc @@ -711,7 +711,9 @@ int CopyupRequest::prepare_copyup_data() { sparse_bufferlist.insert( object_offset, object_length, - {SPARSE_EXTENT_STATE_DATA, object_length, std::move(sub_bl)}); + {SPARSE_EXTENT_STATE_DATA, + static_cast(object_length), + std::move(sub_bl)}); } } else { // copyup that will concurrently written to the HEAD revision with the commit 130fdf7bcfd2b4c5a5b34809952b69b70e9c11a4 Author: Kefu Chai Date: Sat May 8 20:59:07 2021 +0800 mgr/PyModule: use Py_ssize_t for the PyList index also silences the warnings like: mgr/PyModule.cc:574:30: warning: comparison of integer expressions of different signedness: 'unsigned int' and 'Py_ssize_t' {aka 'int'} [-Wsign-compare] 574 | for (unsigned i = 0; i < PyList_Size(p); ++i) { | ~~^~~~~~~~~~~~~~~~ Signed-off-by: Kefu Chai diff --git a/src/mgr/PyModule.cc b/src/mgr/PyModule.cc index 28c76fe7ed..ff1ff85e7e 100644 --- a/src/mgr/PyModule.cc +++ b/src/mgr/PyModule.cc @@ -562,7 +562,7 @@ int PyModule::load_options() } p = PyDict_GetItemString(pOption, "enum_allowed"); if (p && PyObject_TypeCheck(p, &PyList_Type)) { - for (unsigned i = 0; i < PyList_Size(p); ++i) { + for (Py_ssize_t i = 0; i < PyList_Size(p); ++i) { auto q = PyList_GetItem(p, i); if (q) { auto r = PyObject_Str(q); @@ -573,7 +573,7 @@ int PyModule::load_options() } p = PyDict_GetItemString(pOption, "see_also"); if (p && PyObject_TypeCheck(p, &PyList_Type)) { - for (unsigned i = 0; i < PyList_Size(p); ++i) { + for (Py_ssize_t i = 0; i < PyList_Size(p); ++i) { auto q = PyList_GetItem(p, i); if (q && PyObject_TypeCheck(q, &PyUnicode_Type)) { option.see_also.insert(PyUnicode_AsUTF8(q)); @@ -582,7 +582,7 @@ int PyModule::load_options() } p = PyDict_GetItemString(pOption, "tags"); if (p && PyObject_TypeCheck(p, &PyList_Type)) { - for (unsigned i = 0; i < PyList_Size(p); ++i) { + for (Py_ssize_t i = 0; i < PyList_Size(p); ++i) { auto q = PyList_GetItem(p, i); if (q && PyObject_TypeCheck(q, &PyUnicode_Type)) { option.tags.insert(PyUnicode_AsUTF8(q)); commit 3bf4b32c9bd15652b24bc4b8c8ea07fb6bb04357 Author: Kefu Chai Date: Sat May 8 20:51:19 2021 +0800 os/bluestore: print size_t using %xz we cannot assume that size_t is an alias of "long" Signed-off-by: Kefu Chai diff --git a/src/os/bluestore/Allocator.cc b/src/os/bluestore/Allocator.cc index 75f3172ca5..3428545414 100644 --- a/src/os/bluestore/Allocator.cc +++ b/src/os/bluestore/Allocator.cc @@ -81,8 +81,8 @@ public: f->open_object_section("free"); char off_hex[30]; char len_hex[30]; - snprintf(off_hex, sizeof(off_hex) - 1, "0x%lx", off); - snprintf(len_hex, sizeof(len_hex) - 1, "0x%lx", len); + snprintf(off_hex, sizeof(off_hex) - 1, "0x%zx", off); + snprintf(len_hex, sizeof(len_hex) - 1, "0x%zx", len); f->dump_string("offset", off_hex); f->dump_string("length", len_hex); f->close_section(); commit 3af466ee84209896f8671046c837350e736f15de Author: Kefu Chai Date: Sat May 8 20:50:08 2021 +0800 client: print int64_t using PRId64 we cannot assume that int64_t is an alias of "long" Signed-off-by: Kefu Chai diff --git a/src/client/Client.cc b/src/client/Client.cc index acdd8f0934..7352824f6c 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -12772,7 +12772,7 @@ size_t Client::_vxattrcb_cluster_fsid(Inode *in, char *val, size_t size) size_t Client::_vxattrcb_client_id(Inode *in, char *val, size_t size) { auto name = messenger->get_myname(); - return snprintf(val, size, "%s%ld", name.type_str(), name.num()); + return snprintf(val, size, "%s%" PRId64, name.type_str(), name.num()); } #define CEPH_XATTR_NAME(_type, _name) "ceph." #_type "." #_name