From 5a67b34cbd5c2d12e1f482fc0bcc6497dd8d6491 Mon Sep 17 00:00:00 2001 From: Min M Xu Date: Wed, 3 Apr 2024 09:05:04 -0400 Subject: [PATCH] Add -Werror=format-overflow compile flag Some build environment will automatically add -Werror=format-overflow compile flag. Signed-off-by: Min Xu --- teeio-validator/include/ide_test.h | 4 ++-- teeio-validator/teeio_validator/CMakeLists.txt | 2 +- teeio-validator/teeio_validator/scan_pci.c | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/teeio-validator/include/ide_test.h b/teeio-validator/include/ide_test.h index 26ae2dd..38fb90d 100644 --- a/teeio-validator/include/ide_test.h +++ b/teeio-validator/include/ide_test.h @@ -22,8 +22,8 @@ #define MAX_SUPPORTED_PORTS_NUM 16 #define MAX_SUPPORTED_SWITCHES_NUM 16 #define MAX_SUPPORTED_SWITCH_PORTS_NUM 16 -#define PORT_NAME_LENGTH 16 -#define SWITCH_NAME_LENGTH 16 +#define PORT_NAME_LENGTH 32 +#define SWITCH_NAME_LENGTH 32 #define BDF_LENGTH 8 #define DF_LENGTH 5 #define TEST_CASE_DESCRIPTION_LENGTH 32 diff --git a/teeio-validator/teeio_validator/CMakeLists.txt b/teeio-validator/teeio_validator/CMakeLists.txt index 8f229ba..38b7e0b 100644 --- a/teeio-validator/teeio_validator/CMakeLists.txt +++ b/teeio-validator/teeio_validator/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 2.8.12) -ADD_COMPILE_OPTIONS(-Wno-unused-result -Werror) +ADD_COMPILE_OPTIONS(-Wno-unused-result -Werror=format-overflow -Werror) if(CMAKE_BUILD_TYPE STREQUAL "Release") ADD_COMPILE_OPTIONS(-Wno-error=unused-variable -Wno-error=unused-but-set-variable) diff --git a/teeio-validator/teeio_validator/scan_pci.c b/teeio-validator/teeio_validator/scan_pci.c index f00df8d..3c160a7 100644 --- a/teeio-validator/teeio_validator/scan_pci.c +++ b/teeio-validator/teeio_validator/scan_pci.c @@ -41,7 +41,7 @@ bool scan_rp_switch_internal_port_at_bus(IDE_PORT* port, uint8_t bus, uint8_t* S int fd = -1; port->bus = bus; - sprintf(port->bdf, "%02x:%02x.%x", bus, port->device, port->function); + snprintf(port->bdf, BDF_LENGTH, "%02x:%02x.%x", bus, port->device, port->function&0xf); TEEIO_DEBUG((TEEIO_DEBUG_INFO, "Scan %s...\n", port->bdf)); @@ -114,7 +114,7 @@ bool scan_endpoint_at_bus(uint8_t bus, IDE_PORT* port) int fd = -1; port->bus = bus; - sprintf(port->bdf, "%02x:%02x.%x", bus, port->device, port->function); + snprintf(port->bdf, BDF_LENGTH, "%02x:%02x.%x", bus, port->device, port->function&0xf); TEEIO_DEBUG((TEEIO_DEBUG_INFO, "Scan endpoint(%s)...\n", port->bdf));