test/scsi: Assert callocs do not return NULL

Change-Id: I4cf2027c5fbb09e8c451d4c9c40ccee2f55973f2
Signed-off-by: Ziye Yang <ziye.yang@intel.com>
This commit is contained in:
Ziye Yang 2017-03-23 13:43:57 +08:00 committed by Ben Walker
parent 4ed8870958
commit 1a1a8e89a9
2 changed files with 6 additions and 0 deletions

View File

@ -37,6 +37,7 @@ include $(SPDK_ROOT_DIR)/mk/spdk.app.mk
SPDK_LIB_LIST = log
CFLAGS += -I$(SPDK_ROOT_DIR)/test
CFLAGS += -I$(SPDK_ROOT_DIR)/lib/scsi
LIBS += $(SPDK_LIB_LINKER_ARGS)
LIBS += -lcunit

View File

@ -36,6 +36,7 @@
#include <string.h>
#include "CUnit/Basic.h"
#include "spdk_cunit.h"
#include "dev.c"
#include "port.c"
@ -92,6 +93,8 @@ spdk_scsi_lun_construct(const char *name, struct spdk_bdev *bdev)
struct spdk_scsi_lun *lun;
lun = calloc(1, sizeof(struct spdk_scsi_lun));
SPDK_CU_ASSERT_FATAL(lun != NULL);
snprintf(lun->name, sizeof(lun->name), "%s", name);
lun->bdev = bdev;
return lun;
@ -123,6 +126,8 @@ spdk_scsi_lun_claim(struct spdk_scsi_lun *lun)
}
p = calloc(1, sizeof(struct lun_entry));
SPDK_CU_ASSERT_FATAL(p != NULL);
p->lun = lun;
TAILQ_INSERT_TAIL(&g_lun_head, p, lun_entries);