]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: always initialize local variables 31311/head
authorKefu Chai <kchai@redhat.com>
Fri, 1 Nov 2019 05:32:24 +0000 (13:32 +0800)
committerKefu Chai <kchai@redhat.com>
Fri, 1 Nov 2019 05:34:23 +0000 (13:34 +0800)
silence warnings like:

src/librbd/io/ImageRequestWQ.cc:576:7: warning: 'length' may be used uninitialized in this function [-Wmaybe-uninitialized]
       if (block_overlapping_io(&m_in_flight_extents, offset, length)) {
       ^~
...
src/librbd/io/ImageRequestWQ.cc:935:12: note: 'length' was declared here
   uint64_t length;
            ^~~~~~

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

index 1836eb297336e5437533b2d93bc1986ff6259ae0..2a7a0df94fa091d3b68773220eef61fed53a3996 100644 (file)
@@ -931,8 +931,8 @@ void ImageRequestWQ<I>::process_io(ImageDispatchSpec<I> *req,
   const auto& extents = req->get_image_extents();
   bool write_op = req->is_write_op();
   uint64_t tid = req->get_tid();
-  uint64_t offset;
-  uint64_t length;
+  uint64_t offset = 0;
+  uint64_t length = 0;
 
   if (write_op) {
     std::lock_guard locker{m_lock};