Commit b177c568 authored by Daniel Verkamp's avatar Daniel Verkamp
Browse files

nvme: clean up test_nvme_ctrlr_fail



Replace unnecessary allocation with a stack variable.

Clears up a potential NULL pointer dereference indicated by scan-build.

Change-Id: I81a7591729b0f1630bab9ce378716bd2369d6b85
Signed-off-by: default avatarDaniel Verkamp <daniel.verkamp@intel.com>
parent 84cfc97f
Loading
Loading
Loading
Loading
+5 −13
Original line number Diff line number Diff line
@@ -159,22 +159,14 @@ nvme_allocate_request(void *payload, uint32_t payload_size,
}

void
test_nvme_ctrlr_fail()
test_nvme_ctrlr_fail(void)
{
	struct nvme_controller *ctrlr = NULL;
	struct nvme_qpair	qpair = {};
	uint64_t		phys_addr = 0;
	struct nvme_controller	ctrlr = {};

	ctrlr = nvme_malloc("nvme_controller", sizeof(struct nvme_controller),
			    64, &phys_addr);
	CU_ASSERT(ctrlr != NULL);
	ctrlr.num_io_queues = 0;
	nvme_ctrlr_fail(&ctrlr);

	ctrlr->num_io_queues = 0;
	ctrlr->adminq = qpair;
	nvme_ctrlr_fail(ctrlr);

	CU_ASSERT(ctrlr->is_failed == true);
	nvme_free(ctrlr);
	CU_ASSERT(ctrlr.is_failed == true);
}

int main(int argc, char **argv)