test/nvme: Fix bug where ctrlr->nsdata is null

Caught by clang 12 and UBSAN.

Signed-off-by: Ben Walker <benjamin.walker@intel.com>
Change-Id: I2fbb82a9225ab0cb8616bd671f8b81987cb3d708
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/8853
Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Tested-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
This commit is contained in:
Ben Walker 2021-07-20 12:28:43 -07:00 committed by Tomasz Zawadzki
parent 9b420e8c00
commit dc09422cd3

View File

@ -71,7 +71,8 @@ test_nvme_ns_construct(void)
{
struct spdk_nvme_ns ns = {};
uint32_t id = 1;
struct spdk_nvme_ctrlr ctrlr = {};
struct spdk_nvme_ns_data nsdata = {};
struct spdk_nvme_ctrlr ctrlr = { .nsdata = &nsdata };
nvme_ns_construct(&ns, id, &ctrlr);
CU_ASSERT(ns.id == 1);