From a451950958abc17e549268486405c7ab55f6a2f6 Mon Sep 17 00:00:00 2001 From: Nicola Mazzucato Date: Thu, 11 Jul 2019 15:18:16 +0100 Subject: [PATCH] synquacer: Fix GCC 7 -Wformat-truncation error GCC 7 introduces the -Wformat-truncation warning and associated heuristics. This warning identifies potentially unexpected string truncation issues by statically range-checking the vararg inputs to snprintf(). For us, GCC seems to be unable to reliably identify the bounds of the inputs (cluster_idx, core_idx) even though we have static guarantees in place as those guarantees are made in a separate compilation unit from the one in which the error occurs. This patch allows the compiler to inline the cluster/core count functions to ensure it can properly ascertain the proper bounds on the inputs to snprintf(). Change-Id: I2d2b658368531e0e0fc5d1c0b691b61e67a106a6 Signed-off-by: Nicola Mazzucato --- product/synquacer/include/synquacer_core.h | 25 +++++++++++++------ .../synquacer/scp_ramfw/config_scmi_apcore.c | 2 +- product/synquacer/scp_ramfw/firmware.mk | 4 +-- product/synquacer/src/synquacer_core.c | 23 ----------------- 4 files changed, 20 insertions(+), 34 deletions(-) delete mode 100644 product/synquacer/src/synquacer_core.c diff --git a/product/synquacer/include/synquacer_core.h b/product/synquacer/include/synquacer_core.h index 51938e4e3..69c74d320 100644 --- a/product/synquacer/include/synquacer_core.h +++ b/product/synquacer/include/synquacer_core.h @@ -11,17 +11,28 @@ #include /* Maximum number of clusters */ -#define SYNQUACER_CSS_CPUS_CLUSTER_MAX UINT32_C(12) +#define SYNQUACER_CSS_CPUS_CLUSTER UINT32_C(12) /* Maximum number of CPUs per cluster */ -#define SYNQUACER_CSS_CPUS_PER_CLUSTER_MAX UINT32_C(2) +#define SYNQUACER_CSS_CPUS_PER_CLUSTER UINT32_C(2) /* Maximum number of CPUs */ -#define SYNQUACER_CSS_CPUS_MAX \ - (SYNQUACER_CSS_CPUS_CLUSTER_MAX * SYNQUACER_CSS_CPUS_PER_CLUSTER_MAX) +#define SYNQUACER_CSS_CPUS \ + (SYNQUACER_CSS_CPUS_CLUSTER * SYNQUACER_CSS_CPUS_PER_CLUSTER) -uint32_t synquacer_core_get_core_count(void); -uint32_t synquacer_core_get_cluster_count(void); -uint32_t synquacer_core_get_core_per_cluster_count(void); +static inline uint32_t synquacer_core_get_cluster_count(void) +{ + return SYNQUACER_CSS_CPUS_CLUSTER; +} + +static inline uint32_t synquacer_core_get_core_per_cluster_count(void) +{ + return SYNQUACER_CSS_CPUS_PER_CLUSTER; +} + +static inline uint32_t synquacer_core_get_core_count(void) +{ + return SYNQUACER_CSS_CPUS; +} #endif /* SYNQUACER_CORE_H */ diff --git a/product/synquacer/scp_ramfw/config_scmi_apcore.c b/product/synquacer/scp_ramfw/config_scmi_apcore.c index 1443620f7..8ccbf7348 100644 --- a/product/synquacer/scp_ramfw/config_scmi_apcore.c +++ b/product/synquacer/scp_ramfw/config_scmi_apcore.c @@ -16,7 +16,7 @@ static const struct mod_scmi_apcore_reset_register_group reset_reg_group_table[] = { { .base_register = (uintptr_t)&PIK_CLUSTER(0)->RVBARADDR0_LW, - .register_count = SYNQUACER_CSS_CPUS_MAX, + .register_count = SYNQUACER_CSS_CPUS, }, }; diff --git a/product/synquacer/scp_ramfw/firmware.mk b/product/synquacer/scp_ramfw/firmware.mk index 28fc093a1..cafbfe44a 100644 --- a/product/synquacer/scp_ramfw/firmware.mk +++ b/product/synquacer/scp_ramfw/firmware.mk @@ -67,8 +67,6 @@ BS_FIRMWARE_SOURCES := \ config_synquacer_memc.c \ config_system_power.c \ config_timer.c \ - rtx_config.c \ - synquacer_core.c - + rtx_config.c include $(BS_DIR)/firmware.mk diff --git a/product/synquacer/src/synquacer_core.c b/product/synquacer/src/synquacer_core.c deleted file mode 100644 index 5be497bda..000000000 --- a/product/synquacer/src/synquacer_core.c +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Arm SCP/MCP Software - * Copyright (c) 2018-2019, Arm Limited and Contributors. All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -#include - -uint32_t synquacer_core_get_core_count(void) -{ - return SYNQUACER_CSS_CPUS_MAX; -} - -uint32_t synquacer_core_get_cluster_count(void) -{ - return SYNQUACER_CSS_CPUS_CLUSTER_MAX; -} - -uint32_t synquacer_core_get_core_per_cluster_count(void) -{ - return SYNQUACER_CSS_CPUS_PER_CLUSTER_MAX; -} -- GitLab