From 679bf39e5927719d935f465253fe43fd08d84cff Mon Sep 17 00:00:00 2001 From: Seth Howell Date: Thu, 20 Dec 2018 11:17:49 -0700 Subject: [PATCH] test/unit: fix scan-build error in the crypto unittests. The scan-build error this fixes assumes that we do not reallocate an iov_base for the g_bdev_io object in between calls to _crypto_opration_complete. So I explicitly tell it that's what we are doing. Change-Id: Ie15c517ea60a2a527a0520005cb044ab2ba4412e Signed-off-by: Seth Howell Reviewed-on: https://review.gerrithub.io/437988 Tested-by: SPDK CI Jenkins Chandler-Test-Pool: SPDK Automated Test System Reviewed-by: Darek Stojaczyk Reviewed-by: Shuhei Matsumoto Reviewed-by: Changpeng Liu Reviewed-by: yidong0635 --- test/unit/lib/bdev/crypto.c/crypto_ut.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/test/unit/lib/bdev/crypto.c/crypto_ut.c b/test/unit/lib/bdev/crypto.c/crypto_ut.c index ec3ba2320..5b6c51828 100644 --- a/test/unit/lib/bdev/crypto.c/crypto_ut.c +++ b/test/unit/lib/bdev/crypto.c/crypto_ut.c @@ -781,6 +781,10 @@ test_initdrivers(void) static void test_crypto_op_complete(void) { + /* Need to prove to scan-build that we are setting iov_bases properly. */ + void *old_iov_base; + struct crypto_bdev_io *orig_ctx; + /* Make sure completion code respects failure. */ g_bdev_io->internal.status = SPDK_BDEV_IO_STATUS_FAILED; g_completion_called = false; @@ -803,6 +807,8 @@ test_crypto_op_complete(void) MOCK_SET(spdk_bdev_writev_blocks, 0); /* Code under test will free this, if not ASAN will complain. */ g_io_ctx->cry_iov.iov_base = spdk_dma_malloc(16, 0x10, NULL); + orig_ctx = (struct crypto_bdev_io *)g_bdev_io->driver_ctx; + old_iov_base = orig_ctx->cry_iov.iov_base; _crypto_operation_complete(g_bdev_io); CU_ASSERT(g_bdev_io->internal.status == SPDK_BDEV_IO_STATUS_SUCCESS); CU_ASSERT(g_completion_called == true); @@ -814,6 +820,7 @@ test_crypto_op_complete(void) MOCK_SET(spdk_bdev_writev_blocks, -1); /* Code under test will free this, if not ASAN will complain. */ g_io_ctx->cry_iov.iov_base = spdk_dma_malloc(16, 0x10, NULL); + SPDK_CU_ASSERT_FATAL(old_iov_base != orig_ctx->cry_iov.iov_base); _crypto_operation_complete(g_bdev_io); CU_ASSERT(g_bdev_io->internal.status == SPDK_BDEV_IO_STATUS_FAILED); CU_ASSERT(g_completion_called == true);