Commit 1d141f4a authored by Shuhei Matsumoto's avatar Shuhei Matsumoto Committed by Tomasz Zawadzki
Browse files

ut/nvme: Fix nightly test warning of test_nvme_completion_poll_cb() by...


ut/nvme: Fix nightly test warning of test_nvme_completion_poll_cb() by allocating status dynamically

Fix the following warning by allocating status dynamically.

In function ‘nvme_completion_poll_cb’,
    inlined from ‘test_nvme_completion_poll_cb’ at nvme_ut.c:546:2:
/var/jenkins/workspace/unittest-nightly-autotest/spdk/lib/nvme/nvme.c:92:3:
 warning: attempt to free a non-heap object ‘status’ [-Wfree-nonheap-object]
   92 |   free(status);
      |   ^

Signed-off-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: I321b88414f431c8c18617d3ee882b8ab851a70fa
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/1940


Community-CI: Mellanox Build Bot
Community-CI: Broadcom CI
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
parent 1fa071d3
Loading
Loading
Loading
Loading
+9 −5
Original line number Diff line number Diff line
@@ -537,16 +537,20 @@ test_spdk_nvme_detach(void)
static void
test_nvme_completion_poll_cb(void)
{
	struct nvme_completion_poll_status status;
	struct nvme_completion_poll_status *status;
	struct spdk_nvme_cpl cpl;

	memset(&status, 0x0, sizeof(status));
	status = calloc(1, sizeof(*status));
	SPDK_CU_ASSERT_FATAL(status != NULL);

	memset(&cpl, 0xff, sizeof(cpl));

	nvme_completion_poll_cb(&status, &cpl);
	CU_ASSERT(status.done == true);
	CU_ASSERT(memcmp(&cpl, &status.cpl,
	nvme_completion_poll_cb(status, &cpl);
	CU_ASSERT(status->done == true);
	CU_ASSERT(memcmp(&cpl, &status->cpl,
			 sizeof(struct spdk_nvme_cpl)) == 0);

	free(status);
}

/* stub callback used by test_nvme_user_copy_cmd_complete() */