test/event/subsystem: ensure i stays in range
Assert that the number of subsystems doesn't become negative in subsystem_sort_test_depends_on_single(). This also fixes a GCC 7 warning about a possible snprintf() truncation now that the range of i is known to be [1,4]. Change-Id: Idaf8ceab149ff5d786f614f790a8706cae759d38 Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com> Reviewed-on: https://review.gerrithub.io/363496 Tested-by: SPDK Automated Test System <sys_sgsw@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
parent
d199eb295c
commit
0d6f812c8f
@ -35,6 +35,7 @@ SPDK_ROOT_DIR := $(abspath $(CURDIR)/../../../..)
|
||||
include $(SPDK_ROOT_DIR)/mk/spdk.common.mk
|
||||
include $(SPDK_ROOT_DIR)/mk/spdk.app.mk
|
||||
|
||||
CFLAGS += -I$(SPDK_ROOT_DIR)/test
|
||||
CFLAGS += -I$(SPDK_ROOT_DIR)/lib/event
|
||||
APP = subsystem_ut
|
||||
C_SRCS := subsystem_ut.c
|
||||
|
@ -33,7 +33,7 @@
|
||||
|
||||
#include "spdk/stdinc.h"
|
||||
|
||||
#include <CUnit/Basic.h>
|
||||
#include "spdk_cunit.h"
|
||||
|
||||
#include "subsystem.c"
|
||||
|
||||
@ -96,6 +96,7 @@ subsystem_sort_test_depends_on_single(void)
|
||||
i = 4;
|
||||
TAILQ_FOREACH(subsystem, &g_subsystems, tailq) {
|
||||
snprintf(subsystem_name, sizeof(subsystem_name), "subsystem%d", i);
|
||||
SPDK_CU_ASSERT_FATAL(i > 0);
|
||||
i--;
|
||||
CU_ASSERT(strcmp(subsystem_name, subsystem->name) == 0);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user