Commit 0d6f812c authored by Daniel Verkamp's avatar Daniel Verkamp
Browse files

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: default avatarDaniel Verkamp <daniel.verkamp@intel.com>
Reviewed-on: https://review.gerrithub.io/363496


Tested-by: default avatarSPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
parent d199eb29
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -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
+2 −1
Original line number Diff line number Diff line
@@ -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);
	}