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 <seth.howell@intel.com>
Reviewed-on: https://review.gerrithub.io/437988
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: yidong0635 <dongx.yi@intel.com>
This commit is contained in:
Seth Howell 2018-12-20 11:17:49 -07:00 committed by Darek Stojaczyk
parent 36325127b5
commit 679bf39e59

View File

@ -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);