From be1f8549b4b42c3b996357eef2800e9734b32771 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Sun, 6 Oct 2019 18:08:24 +0800 Subject: [PATCH] os/bluestore: use in-class initialization for better readability Signed-off-by: Kefu Chai --- src/os/bluestore/BlockDevice.h | 6 ++---- src/os/bluestore/BlueFS.h | 12 +++++------- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/src/os/bluestore/BlockDevice.h b/src/os/bluestore/BlockDevice.h index ee1afc63109bc..0ef84b91b627a 100644 --- a/src/os/bluestore/BlockDevice.h +++ b/src/os/bluestore/BlockDevice.h @@ -138,8 +138,8 @@ private: std::atomic_int ioc_reap_count = {0}; protected: - uint64_t size; - uint64_t block_size; + uint64_t size = 0; + uint64_t block_size = 0; bool support_discard = false; bool rotational = true; bool lock_exclusive = true; @@ -149,8 +149,6 @@ public: void *aio_callback_priv; BlockDevice(CephContext* cct, aio_callback_t cb, void *cbpriv) : cct(cct), - size(0), - block_size(0), aio_callback(cb), aio_callback_priv(cbpriv) {} diff --git a/src/os/bluestore/BlueFS.h b/src/os/bluestore/BlueFS.h index 683e992370488..35697b667f63c 100644 --- a/src/os/bluestore/BlueFS.h +++ b/src/os/bluestore/BlueFS.h @@ -194,20 +194,18 @@ public: struct FileReaderBuffer { MEMPOOL_CLASS_HELPERS(); - uint64_t bl_off; ///< prefetch buffer logical offset + uint64_t bl_off = 0; ///< prefetch buffer logical offset bufferlist bl; ///< prefetch buffer - uint64_t pos; ///< current logical offset + uint64_t pos = 0; ///< current logical offset uint64_t max_prefetch; ///< max allowed prefetch explicit FileReaderBuffer(uint64_t mpf) - : bl_off(0), - pos(0), - max_prefetch(mpf) {} + : max_prefetch(mpf) {} - uint64_t get_buf_end() { + uint64_t get_buf_end() const { return bl_off + bl.length(); } - uint64_t get_buf_remaining(uint64_t p) { + uint64_t get_buf_remaining(uint64_t p) const { if (p >= bl_off && p < bl_off + bl.length()) return bl_off + bl.length() - p; return 0; -- 2.39.5