ut/nvme_fabric: Fix access to local variable after returning from the function
Fix issue #1936 Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Change-Id: Iaa2b8060053d3f798001a6b207a6fcb0335c4b23 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/7833 Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com> Reviewed-by: Changpeng Liu <changpeng.liu@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Ziye Yang <ziye.yang@intel.com> Reviewed-by: <dongx.yi@intel.com> Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
parent
53447f060f
commit
646f41476d
@ -113,13 +113,15 @@ spdk_nvme_transport_id_populate_trstring(struct spdk_nvme_transport_id *trid, co
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct spdk_nvme_transport_id *g_ut_trid;
|
||||
static struct spdk_nvme_transport_id g_ut_trid;
|
||||
static bool g_ut_ctrlr_is_probed;
|
||||
|
||||
int
|
||||
nvme_ctrlr_probe(const struct spdk_nvme_transport_id *trid,
|
||||
struct spdk_nvme_probe_ctx *probe_ctx, void *devhandle)
|
||||
{
|
||||
g_ut_trid = trid;
|
||||
g_ut_trid = *trid;
|
||||
g_ut_ctrlr_is_probed = true;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -276,30 +278,30 @@ test_nvme_fabric_discover_probe(void)
|
||||
memcpy(entry.trsvcid, trsvcid, SPDK_NVMF_TRSVCID_MAX_LEN);
|
||||
memcpy(probe_ctx.trid.trstring, trstring, sizeof(probe_ctx.trid.trstring));
|
||||
|
||||
g_ut_trid = NULL;
|
||||
nvme_fabric_discover_probe(&entry, &probe_ctx, 1);
|
||||
CU_ASSERT(g_ut_trid != NULL);
|
||||
CU_ASSERT(g_ut_trid->trtype == SPDK_NVME_TRANSPORT_RDMA);
|
||||
CU_ASSERT(g_ut_trid->adrfam == SPDK_NVMF_ADRFAM_IPV4);
|
||||
CU_ASSERT(!strncmp(g_ut_trid->trstring, trstring, sizeof(trstring)));
|
||||
CU_ASSERT(!strncmp(g_ut_trid->subnqn, hostnqn, sizeof(hostnqn)));
|
||||
CU_ASSERT(!strncmp(g_ut_trid->traddr, traddr, sizeof(traddr)));
|
||||
CU_ASSERT(!strncmp(g_ut_trid->trsvcid, trsvcid, sizeof(trsvcid)));
|
||||
CU_ASSERT(g_ut_trid->priority == 1);
|
||||
CU_ASSERT(g_ut_ctrlr_is_probed == true);
|
||||
CU_ASSERT(g_ut_trid.trtype == SPDK_NVME_TRANSPORT_RDMA);
|
||||
CU_ASSERT(g_ut_trid.adrfam == SPDK_NVMF_ADRFAM_IPV4);
|
||||
CU_ASSERT(!strncmp(g_ut_trid.trstring, trstring, sizeof(trstring)));
|
||||
CU_ASSERT(!strncmp(g_ut_trid.subnqn, hostnqn, sizeof(hostnqn)));
|
||||
CU_ASSERT(!strncmp(g_ut_trid.traddr, traddr, sizeof(traddr)));
|
||||
CU_ASSERT(!strncmp(g_ut_trid.trsvcid, trsvcid, sizeof(trsvcid)));
|
||||
CU_ASSERT(g_ut_trid.priority == 1);
|
||||
|
||||
g_ut_ctrlr_is_probed = false;
|
||||
memset(&g_ut_trid, 0, sizeof(g_ut_trid));
|
||||
|
||||
/* Entry type unsupported */
|
||||
entry.subtype = SPDK_NVMF_SUBTYPE_DISCOVERY;
|
||||
g_ut_trid = NULL;
|
||||
|
||||
nvme_fabric_discover_probe(&entry, &probe_ctx, 1);
|
||||
CU_ASSERT(g_ut_trid == NULL);
|
||||
CU_ASSERT(g_ut_ctrlr_is_probed == false);
|
||||
|
||||
/* Entry type invalid */
|
||||
entry.subtype = 3;
|
||||
g_ut_trid = NULL;
|
||||
|
||||
nvme_fabric_discover_probe(&entry, &probe_ctx, 1);
|
||||
CU_ASSERT(g_ut_trid == NULL);
|
||||
CU_ASSERT(g_ut_ctrlr_is_probed == false);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
|
Loading…
Reference in New Issue
Block a user