Commit 84009795 authored by Seth Howell's avatar Seth Howell Committed by Jim Harris
Browse files

test/unit: fix Scan-build errors in lvol tests.



Fixes two null pointer dereference errors.

Change-Id: I7d685fa54af60e6efd70f3686d4dc4dba338f555
Signed-off-by: default avatarSeth Howell <seth.howell@intel.com>
Reviewed-on: https://review.gerrithub.io/424108


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
parent 2e6aac52
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -1051,6 +1051,7 @@ spdk_lvol_create(struct spdk_lvol_store *lvs, const char *name, uint64_t sz,
		return rc;
	}

	assert(lvs != NULL);
	bs = lvs->blobstore;

	req = calloc(1, sizeof(*req));
+11 −8
Original line number Diff line number Diff line
@@ -1851,6 +1851,7 @@ static void lvol_refcnt(void)
{
	struct lvol_ut_bs_dev dev;
	struct spdk_lvs_opts opts;
	struct spdk_lvol *lvol;
	int rc = 0;

	init_dev(&dev);
@@ -1872,24 +1873,26 @@ static void lvol_refcnt(void)
	SPDK_CU_ASSERT_FATAL(g_lvol != NULL);
	CU_ASSERT(g_lvol->ref_count == 1);

	lvol = g_lvol;
	spdk_lvol_open(g_lvol, lvol_op_with_handle_complete, NULL);
	CU_ASSERT(g_lvol->ref_count == 2);
	SPDK_CU_ASSERT_FATAL(g_lvol != NULL);
	CU_ASSERT(lvol->ref_count == 2);

	/* Trying to destroy lvol while its open should fail */
	spdk_lvol_destroy(g_lvol, lvol_op_complete, NULL);
	spdk_lvol_destroy(lvol, lvol_op_complete, NULL);
	CU_ASSERT(g_lvolerrno != 0);

	spdk_lvol_close(g_lvol, lvol_op_complete, NULL);
	CU_ASSERT(g_lvol->ref_count == 1);
	spdk_lvol_close(lvol, lvol_op_complete, NULL);
	CU_ASSERT(lvol->ref_count == 1);
	CU_ASSERT(g_lvolerrno == 0);

	spdk_lvol_close(g_lvol, lvol_op_complete, NULL);
	CU_ASSERT(g_lvol->ref_count == 0);
	spdk_lvol_close(lvol, lvol_op_complete, NULL);
	CU_ASSERT(lvol->ref_count == 0);
	CU_ASSERT(g_lvolerrno == 0);

	/* Try to close already closed lvol */
	spdk_lvol_close(g_lvol, lvol_op_complete, NULL);
	CU_ASSERT(g_lvol->ref_count == 0);
	spdk_lvol_close(lvol, lvol_op_complete, NULL);
	CU_ASSERT(lvol->ref_count == 0);
	CU_ASSERT(g_lvolerrno != 0);

	g_lvserrno = -1;