From 9c3774681b51e5d88ec3601ac640eda438a71bd4 Mon Sep 17 00:00:00 2001 From: Hailiang Wang Date: Tue, 2 Jul 2019 15:06:12 +0800 Subject: [PATCH] test/bdev_raid_ut: fix a warning of a null pointer dereference Compilation Warning on fedora30. bdev_raid_ut.c:659:13: warning: Array access (via field 'base_channel') results in a null pointer dereference CU_ASSERT(ch_ctx->base_channel[index] == g_io_output[index].ch); ^~~~~~~~~~~~~~~~~~~~~~~~~~~ bdev_raid_ut.c:2181:14: warning: Array access (via field 'base_channel') results in a null pointer dereference CU_ASSERT(ch_ctx->base_channel[j] == (void *)0x1); ^~~~~~~~~~~~~~~~~~~~~~~ This is related to issue #822. Change-Id: I9fd066b16e9f4c1fedc95403d2ac6e609f862c65 Signed-off-by: Hailiang Wang Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/460094 Tested-by: SPDK CI Jenkins Reviewed-by: Shuhei Matsumoto Reviewed-by: Changpeng Liu --- test/unit/lib/bdev/bdev_raid.c/bdev_raid_ut.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/unit/lib/bdev/bdev_raid.c/bdev_raid_ut.c b/test/unit/lib/bdev/bdev_raid.c/bdev_raid_ut.c index 22fd88928..e1c012a96 100644 --- a/test/unit/lib/bdev/bdev_raid.c/bdev_raid_ut.c +++ b/test/unit/lib/bdev/bdev_raid.c/bdev_raid_ut.c @@ -653,6 +653,7 @@ verify_reset_io(struct spdk_bdev_io *bdev_io, uint8_t num_base_drives, SPDK_CU_ASSERT_FATAL(raid_bdev != NULL); SPDK_CU_ASSERT_FATAL(num_base_drives != 0); SPDK_CU_ASSERT_FATAL(io_status != INVALID_IO_SUBMIT); + SPDK_CU_ASSERT_FATAL(ch_ctx->base_channel != NULL); CU_ASSERT(g_io_output_index == num_base_drives); for (index = 0; index < g_io_output_index; index++) { @@ -2176,7 +2177,7 @@ test_multi_raid_with_io(void) ch_ctx = spdk_io_channel_get_ctx(&ch[i]); SPDK_CU_ASSERT_FATAL(ch_ctx != NULL); CU_ASSERT(raid_bdev_create_cb(pbdev, ch_ctx) == 0); - CU_ASSERT(ch_ctx->base_channel != NULL); + SPDK_CU_ASSERT_FATAL(ch_ctx->base_channel != NULL); for (j = 0; j < construct_req[i].base_bdevs.num_base_bdevs; j++) { CU_ASSERT(ch_ctx->base_channel[j] == (void *)0x1); }