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:
parent
4ed8870958
commit
1a1a8e89a9
@ -37,6 +37,7 @@ include $(SPDK_ROOT_DIR)/mk/spdk.app.mk
|
|||||||
|
|
||||||
SPDK_LIB_LIST = log
|
SPDK_LIB_LIST = log
|
||||||
|
|
||||||
|
CFLAGS += -I$(SPDK_ROOT_DIR)/test
|
||||||
CFLAGS += -I$(SPDK_ROOT_DIR)/lib/scsi
|
CFLAGS += -I$(SPDK_ROOT_DIR)/lib/scsi
|
||||||
LIBS += $(SPDK_LIB_LINKER_ARGS)
|
LIBS += $(SPDK_LIB_LINKER_ARGS)
|
||||||
LIBS += -lcunit
|
LIBS += -lcunit
|
||||||
|
@ -36,6 +36,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "CUnit/Basic.h"
|
#include "CUnit/Basic.h"
|
||||||
|
#include "spdk_cunit.h"
|
||||||
|
|
||||||
#include "dev.c"
|
#include "dev.c"
|
||||||
#include "port.c"
|
#include "port.c"
|
||||||
@ -92,6 +93,8 @@ spdk_scsi_lun_construct(const char *name, struct spdk_bdev *bdev)
|
|||||||
struct spdk_scsi_lun *lun;
|
struct spdk_scsi_lun *lun;
|
||||||
|
|
||||||
lun = calloc(1, sizeof(struct spdk_scsi_lun));
|
lun = calloc(1, sizeof(struct spdk_scsi_lun));
|
||||||
|
SPDK_CU_ASSERT_FATAL(lun != NULL);
|
||||||
|
|
||||||
snprintf(lun->name, sizeof(lun->name), "%s", name);
|
snprintf(lun->name, sizeof(lun->name), "%s", name);
|
||||||
lun->bdev = bdev;
|
lun->bdev = bdev;
|
||||||
return lun;
|
return lun;
|
||||||
@ -123,6 +126,8 @@ spdk_scsi_lun_claim(struct spdk_scsi_lun *lun)
|
|||||||
}
|
}
|
||||||
|
|
||||||
p = calloc(1, sizeof(struct lun_entry));
|
p = calloc(1, sizeof(struct lun_entry));
|
||||||
|
SPDK_CU_ASSERT_FATAL(p != NULL);
|
||||||
|
|
||||||
p->lun = lun;
|
p->lun = lun;
|
||||||
|
|
||||||
TAILQ_INSERT_TAIL(&g_lun_head, p, lun_entries);
|
TAILQ_INSERT_TAIL(&g_lun_head, p, lun_entries);
|
||||||
|
Loading…
Reference in New Issue
Block a user