From 0d6f812c8f0337a1d28c3d15055296bfb21e9e8f Mon Sep 17 00:00:00 2001 From: Daniel Verkamp Date: Thu, 1 Jun 2017 23:55:11 -0700 Subject: [PATCH] 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 Reviewed-on: https://review.gerrithub.io/363496 Tested-by: SPDK Automated Test System Reviewed-by: Ben Walker --- test/lib/event/subsystem/Makefile | 1 + test/lib/event/subsystem/subsystem_ut.c | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/test/lib/event/subsystem/Makefile b/test/lib/event/subsystem/Makefile index 30d199d96..554fece31 100644 --- a/test/lib/event/subsystem/Makefile +++ b/test/lib/event/subsystem/Makefile @@ -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 diff --git a/test/lib/event/subsystem/subsystem_ut.c b/test/lib/event/subsystem/subsystem_ut.c index 00360138a..427e3aae2 100644 --- a/test/lib/event/subsystem/subsystem_ut.c +++ b/test/lib/event/subsystem/subsystem_ut.c @@ -33,7 +33,7 @@ #include "spdk/stdinc.h" -#include +#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); }