From 9714818d04cfc757511adaa0efdc32f907fb2ed4 Mon Sep 17 00:00:00 2001 From: yidong0635 Date: Thu, 15 Oct 2020 08:22:40 -0400 Subject: [PATCH] test/bdev_ut: fix warning about unitialize value. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit gcc version 10.1.1 20200619 releases/gcc-10.1.0-223-gf8e16e23d0 (Clear Linux OS for Intel Architecture) Issue reports: CC test/unit/lib/nvme/nvme_ns_cmd.c/nvme_ns_cmd_ut.o bdev_ut.c: In function ‘bdev_io_alignment_with_boundary’: bdev_ut.c:2146:2: error: ‘buf’ may be used uninitialized in this function [-Werror=maybe-uninitialized] 2146 | free(buf); | ^~~~~~~~~ bdev_ut.c: In function ‘bdev_io_alignment’: bdev_ut.c:2008:2: error: ‘buf’ may be used uninitialized in this function [-Werror=maybe-uninitialized] 2008 | free(buf); | ^~~~~~~~~ Signed-off-by: yidong0635 Change-Id: I6d1bbf74b230b7bc51646454ddba0db4792f5900 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/4693 Reviewed-by: Changpeng Liu Reviewed-by: Shuhei Matsumoto Tested-by: SPDK CI Jenkins --- test/unit/lib/bdev/bdev.c/bdev_ut.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/unit/lib/bdev/bdev.c/bdev_ut.c b/test/unit/lib/bdev/bdev.c/bdev_ut.c index 36916f4f5..c5e0d8de1 100644 --- a/test/unit/lib/bdev/bdev.c/bdev_ut.c +++ b/test/unit/lib/bdev/bdev.c/bdev_ut.c @@ -1800,7 +1800,7 @@ bdev_io_alignment(void) .bdev_io_cache_size = 2, }; int rc; - void *buf; + void *buf = NULL; struct iovec iovs[2]; int iovcnt; uint64_t alignment; @@ -2019,7 +2019,7 @@ bdev_io_alignment_with_boundary(void) .bdev_io_cache_size = 2, }; int rc; - void *buf; + void *buf = NULL; struct iovec iovs[2]; int iovcnt; uint64_t alignment;