From 7b67a696da4eff2962caf18fee1ae2a87cadf2d2 Mon Sep 17 00:00:00 2001 From: GangCao Date: Tue, 18 Jan 2022 19:03:39 -0500 Subject: [PATCH] UT/NVMe: Fix compilation warnings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix warning: missing braces around initializer This issue is seen with gcc (GCC) 4.8.5 20150623. Warning like below: nvme_tcp_ut.c:243:9: warning: (near initialization for ‘ctrlr.ns’) [-Wmissing-braces] nvme_tcp_ut.c: In function ‘test_nvme_tcp_req_init’: nvme_tcp_ut.c:525:9: warning: missing braces around initializer [-Wmissing-braces] struct spdk_nvme_ctrlr ctrlr = {0}; ^ nvme_tcp_ut.c:525:9: warning: (near initialization for ‘ctrlr.ns’) [-Wmissing-braces] And more information from below link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53119 Change-Id: I88b5b3908d5d0daa9383e47a1ed53288f342ca3b Signed-off-by: GangCao Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/11137 Reviewed-by: Aleksey Marchuk Reviewed-by: Shuhei Matsumoto Reviewed-by: Changpeng Liu Tested-by: SPDK CI Jenkins Community-CI: Broadcom CI Community-CI: Mellanox Build Bot --- test/unit/lib/nvme/nvme_ctrlr.c/nvme_ctrlr_ut.c | 4 ++-- test/unit/lib/nvme/nvme_ns_cmd.c/nvme_ns_cmd_ut.c | 4 ++-- test/unit/lib/nvme/nvme_qpair.c/nvme_qpair_ut.c | 2 +- test/unit/lib/nvme/nvme_tcp.c/nvme_tcp_ut.c | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/test/unit/lib/nvme/nvme_ctrlr.c/nvme_ctrlr_ut.c b/test/unit/lib/nvme/nvme_ctrlr.c/nvme_ctrlr_ut.c index 56662614d1..fa3665b2ff 100644 --- a/test/unit/lib/nvme/nvme_ctrlr.c/nvme_ctrlr_ut.c +++ b/test/unit/lib/nvme/nvme_ctrlr.c/nvme_ctrlr_ut.c @@ -2266,8 +2266,8 @@ test_nvme_ctrlr_init_delay(void) static void test_spdk_nvme_ctrlr_set_trid(void) { - struct spdk_nvme_ctrlr ctrlr = {0}; - struct spdk_nvme_transport_id new_trid = {{0}}; + struct spdk_nvme_ctrlr ctrlr = {{0}}; + struct spdk_nvme_transport_id new_trid = {{0}}; CU_ASSERT(pthread_mutex_init(&ctrlr.ctrlr_lock, NULL) == 0); diff --git a/test/unit/lib/nvme/nvme_ns_cmd.c/nvme_ns_cmd_ut.c b/test/unit/lib/nvme/nvme_ns_cmd.c/nvme_ns_cmd_ut.c index 48c0b6addc..b82f7adfb2 100644 --- a/test/unit/lib/nvme/nvme_ns_cmd.c/nvme_ns_cmd_ut.c +++ b/test/unit/lib/nvme/nvme_ns_cmd.c/nvme_ns_cmd_ut.c @@ -594,7 +594,7 @@ static void test_nvme_ns_cmd_write_zeroes(void) { struct spdk_nvme_ns ns = { 0 }; - struct spdk_nvme_ctrlr ctrlr = { 0 }; + struct spdk_nvme_ctrlr ctrlr = {{0}}; struct spdk_nvme_qpair qpair; spdk_nvme_cmd_cb cb_fn = NULL; void *cb_arg = NULL; @@ -621,7 +621,7 @@ static void test_nvme_ns_cmd_write_uncorrectable(void) { struct spdk_nvme_ns ns = { 0 }; - struct spdk_nvme_ctrlr ctrlr = { 0 }; + struct spdk_nvme_ctrlr ctrlr = {{0}}; struct spdk_nvme_qpair qpair; spdk_nvme_cmd_cb cb_fn = NULL; void *cb_arg = NULL; diff --git a/test/unit/lib/nvme/nvme_qpair.c/nvme_qpair_ut.c b/test/unit/lib/nvme/nvme_qpair.c/nvme_qpair_ut.c index 132468bfcb..aeea8c8eb9 100644 --- a/test/unit/lib/nvme/nvme_qpair.c/nvme_qpair_ut.c +++ b/test/unit/lib/nvme/nvme_qpair.c/nvme_qpair_ut.c @@ -179,7 +179,7 @@ static void test_nvme_qpair_process_completions(void) { struct spdk_nvme_qpair admin_qp = {0}; struct spdk_nvme_qpair qpair = {0}; - struct spdk_nvme_ctrlr ctrlr = {0}; + struct spdk_nvme_ctrlr ctrlr = {{0}}; struct nvme_request dummy_1 = {{0}}; struct nvme_request dummy_2 = {{0}}; int rc; diff --git a/test/unit/lib/nvme/nvme_tcp.c/nvme_tcp_ut.c b/test/unit/lib/nvme/nvme_tcp.c/nvme_tcp_ut.c index bdcf5ec821..091b5ded4a 100644 --- a/test/unit/lib/nvme/nvme_tcp.c/nvme_tcp_ut.c +++ b/test/unit/lib/nvme/nvme_tcp.c/nvme_tcp_ut.c @@ -240,7 +240,7 @@ static void test_nvme_tcp_build_sgl_request(void) { struct nvme_tcp_qpair tqpair; - struct spdk_nvme_ctrlr ctrlr = {0}; + struct spdk_nvme_ctrlr ctrlr = {{0}}; struct nvme_tcp_req tcp_req = {0}; struct nvme_request req = {{0}}; struct nvme_tcp_ut_bdev_io bio; @@ -522,7 +522,7 @@ test_nvme_tcp_req_init(void) struct nvme_tcp_qpair tqpair = {}; struct nvme_request req = {}; struct nvme_tcp_req tcp_req = {0}; - struct spdk_nvme_ctrlr ctrlr = {0}; + struct spdk_nvme_ctrlr ctrlr = {{0}}; struct nvme_tcp_ut_bdev_io bio = {}; int rc;