OSDN Git Service

block: fix build warning in merging bvecs
authorMing Lei <ming.lei@redhat.com>
Tue, 2 Apr 2019 02:26:44 +0000 (10:26 +0800)
committerJens Axboe <axboe@kernel.dk>
Mon, 8 Apr 2019 16:57:10 +0000 (10:57 -0600)
commitb21e11c5c8311b8bf6923ff29d57f2a5f997e939
tree0c2becff5ec805afd350fd73e8f446f52f925de9
parent636b8fe86bede8c9f797365986b8406ff2183f13
block: fix build warning in merging bvecs

Commit f6970f83ef79 ("block: don't check if adjacent bvecs in one bio can
be mergeable") changes bvec merge by only considering two bvecs from
different bios. However, if the former bio doesn't inlcude any io bvec,
then the following warning may be triggered:

 warning: ‘bvec.bv_offset’ may be used uninitialized in this function [-Wmaybe-uninitialized]

In practice, it shouldn't be triggered.

Fixes it by adding check on former bio, the check shouldn't add any cost
given 'bio->bi_iter' can be hit in cache.

Reported-by: Jens Axboe <axboe@kernel.dk>
Fixes: f6970f83ef79 ("block: don't check if adjacent bvecs in one bio can be mergeable")
Signed-off-by: Ming Lei <ming.lei@redhat.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
block/blk-merge.c