From e7c645b5206bc9fc3c5ac9089e3fd5b84d7ca216 Mon Sep 17 00:00:00 2001 From: Yann Gautier Date: Mon, 10 Dec 2018 18:00:26 +0100 Subject: [PATCH 1/4] Add the possibility to compile TF-A with more warnings The list of warning is taken from kernel and also divided in 3. The option to activate that is W=x, with x=1, 2 or 3. Signed-off-by: Yann Gautier --- Makefile | 40 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index eed7c7a85..5841345eb 100644 --- a/Makefile +++ b/Makefile @@ -188,8 +188,46 @@ TF_CFLAGS_aarch64 += -mgeneral-regs-only -mstrict-align ASFLAGS_aarch32 = $(march32-directive) ASFLAGS_aarch64 = -march=armv8-a +WARNING1 := -Wextra +WARNING1 += -Wunused -Wno-unused-parameter +WARNING1 += -Wmissing-declarations +WARNING1 += -Wmissing-format-attribute +WARNING1 += -Wmissing-prototypes +WARNING1 += -Wold-style-definition +WARNING1 += -Wunused-but-set-variable +WARNING1 += -Wunused-const-variable + +WARNING2 := -Waggregate-return +WARNING2 += -Wcast-align +WARNING2 += -Wdisabled-optimization +WARNING2 += -Wnested-externs +WARNING2 += -Wshadow +WARNING2 += -Wlogical-op +WARNING2 += -Wmissing-field-initializers +WARNING2 += -Wsign-compare +WARNING2 += -Wmaybe-uninitialized + +WARNING3 := -Wbad-function-cast +WARNING3 += -Wcast-qual +WARNING3 += -Wconversion +WARNING3 += -Wpacked +WARNING3 += -Wpadded +WARNING3 += -Wpointer-arith +WARNING3 += -Wredundant-decls +WARNING3 += -Wswitch-default +WARNING3 += -Wpacked-bitfield-compat +WARNING3 += -Wvla + +ifeq (${W},1) +WARNINGS := $(WARNING1) +else ifeq (${W},2) +WARNINGS := $(WARNING1) $(WARNING2) +else ifeq (${W},3) +WARNINGS := $(WARNING1) $(WARNING2) $(WARNING3) +endif + CPPFLAGS = ${DEFINES} ${INCLUDES} ${MBEDTLS_INC} -nostdinc \ - -Wmissing-include-dirs -Werror + -Wmissing-include-dirs -Werror $(WARNINGS) ASFLAGS += $(CPPFLAGS) $(ASFLAGS_$(ARCH)) \ -D__ASSEMBLY__ -ffreestanding \ -Wa,--fatal-warnings From b7c6529c412d53b74e2a1fb6a7b1a70438a02802 Mon Sep 17 00:00:00 2001 From: Yann Gautier Date: Mon, 3 Dec 2018 13:38:06 +0100 Subject: [PATCH 2/4] io_block: define MAX_IO_BLOCK_DEVICES as unsigned This is used as a table index, and already compared with an unsigned int: block_dev_count. Signed-off-by: Yann Gautier --- drivers/io/io_block.c | 4 +++- plat/hisilicon/hikey/include/platform_def.h | 2 +- plat/hisilicon/hikey960/include/platform_def.h | 2 +- plat/hisilicon/poplar/include/platform_def.h | 2 +- plat/imx/imx7/warp7/include/platform_def.h | 2 +- plat/socionext/uniphier/include/platform_def.h | 2 +- 6 files changed, 8 insertions(+), 6 deletions(-) diff --git a/drivers/io/io_block.c b/drivers/io/io_block.c index 8226554d9..ff13113af 100644 --- a/drivers/io/io_block.c +++ b/drivers/io/io_block.c @@ -67,8 +67,10 @@ io_type_t device_type_block(void) static int find_first_block_state(const io_block_dev_spec_t *dev_spec, unsigned int *index_out) { + unsigned int index; int result = -ENOENT; - for (int index = 0; index < MAX_IO_BLOCK_DEVICES; ++index) { + + for (index = 0U; index < MAX_IO_BLOCK_DEVICES; ++index) { /* dev_spec is used as identifier since it's unique */ if (state_pool[index].dev_spec == dev_spec) { result = 0; diff --git a/plat/hisilicon/hikey/include/platform_def.h b/plat/hisilicon/hikey/include/platform_def.h index f2d358a7b..485eb3800 100644 --- a/plat/hisilicon/hikey/include/platform_def.h +++ b/plat/hisilicon/hikey/include/platform_def.h @@ -41,7 +41,7 @@ #define MAX_IO_DEVICES 3 #define MAX_IO_HANDLES 4 /* eMMC RPMB and eMMC User Data */ -#define MAX_IO_BLOCK_DEVICES 2 +#define MAX_IO_BLOCK_DEVICES U(2) /* GIC related constants (no GICR in GIC-400) */ #define PLAT_ARM_GICD_BASE 0xF6801000 diff --git a/plat/hisilicon/hikey960/include/platform_def.h b/plat/hisilicon/hikey960/include/platform_def.h index 3717ff8af..427a1e759 100644 --- a/plat/hisilicon/hikey960/include/platform_def.h +++ b/plat/hisilicon/hikey960/include/platform_def.h @@ -38,7 +38,7 @@ #define MAX_IO_DEVICES 3 #define MAX_IO_HANDLES 4 /* UFS RPMB and UFS User Data */ -#define MAX_IO_BLOCK_DEVICES 2 +#define MAX_IO_BLOCK_DEVICES U(2) /* diff --git a/plat/hisilicon/poplar/include/platform_def.h b/plat/hisilicon/poplar/include/platform_def.h index 6287a76aa..e39d94471 100644 --- a/plat/hisilicon/poplar/include/platform_def.h +++ b/plat/hisilicon/poplar/include/platform_def.h @@ -40,7 +40,7 @@ /* IO framework user */ #define MAX_IO_DEVICES (4) #define MAX_IO_HANDLES (4) -#define MAX_IO_BLOCK_DEVICES (2) +#define MAX_IO_BLOCK_DEVICES U(2) /* Memory size options */ #define POPLAR_DRAM_SIZE_1G 0 diff --git a/plat/imx/imx7/warp7/include/platform_def.h b/plat/imx/imx7/warp7/include/platform_def.h index d0148f422..4ee6fd37d 100644 --- a/plat/imx/imx7/warp7/include/platform_def.h +++ b/plat/imx/imx7/warp7/include/platform_def.h @@ -169,7 +169,7 @@ #define MAX_XLAT_TABLES 6 #define MAX_IO_DEVICES 2 #define MAX_IO_HANDLES 3 -#define MAX_IO_BLOCK_DEVICES 1 +#define MAX_IO_BLOCK_DEVICES 1U /* UART defines */ #if PLAT_WARP7_UART == 1 diff --git a/plat/socionext/uniphier/include/platform_def.h b/plat/socionext/uniphier/include/platform_def.h index 3d71db205..6e9b98edb 100644 --- a/plat/socionext/uniphier/include/platform_def.h +++ b/plat/socionext/uniphier/include/platform_def.h @@ -53,7 +53,7 @@ #define MAX_IO_HANDLES 2 #define MAX_IO_DEVICES 2 -#define MAX_IO_BLOCK_DEVICES 1 +#define MAX_IO_BLOCK_DEVICES U(1) #define TSP_SEC_MEM_BASE (BL32_BASE) #define TSP_SEC_MEM_SIZE ((BL32_LIMIT) - (BL32_BASE)) From 1b18c6c47185fd83682c77de510c43d8d5d200df Mon Sep 17 00:00:00 2001 From: Yann Gautier Date: Mon, 10 Dec 2018 10:41:03 +0100 Subject: [PATCH 3/4] correct some missing-prototype warnings This avoids the following warnings: no previous prototype for 'bl2_arch_setup' [-Wmissing-prototypes] no previous prototype for 'plat_log_get_prefix' [-Wmissing-prototypes] Also correct a compilation issue if BL2_IN_XIP_MEM is enabled: uintptr_t is not defined. Signed-off-by: Lionel Debieve Signed-off-by: Yann Gautier --- bl2/aarch32/bl2_arch_setup.c | 1 + bl2/bl2_private.h | 3 +++ plat/common/plat_log_common.c | 1 + 3 files changed, 5 insertions(+) diff --git a/bl2/aarch32/bl2_arch_setup.c b/bl2/aarch32/bl2_arch_setup.c index db8a068a1..4fd8d0725 100644 --- a/bl2/aarch32/bl2_arch_setup.c +++ b/bl2/aarch32/bl2_arch_setup.c @@ -4,6 +4,7 @@ * SPDX-License-Identifier: BSD-3-Clause */ +#include "../bl2_private.h" /******************************************************************************* * Place holder function to perform any Secure SVC specific architectural diff --git a/bl2/bl2_private.h b/bl2/bl2_private.h index 7fd17bfe4..01f6c6bd2 100644 --- a/bl2/bl2_private.h +++ b/bl2/bl2_private.h @@ -8,6 +8,9 @@ #define BL2_PRIVATE_H #if BL2_IN_XIP_MEM + +#include + /******************************************************************************* * Declarations of linker defined symbols which will tell us where BL2 lives * in Trusted ROM and RAM diff --git a/plat/common/plat_log_common.c b/plat/common/plat_log_common.c index 49e1c152f..c757c6bf1 100644 --- a/plat/common/plat_log_common.c +++ b/plat/common/plat_log_common.c @@ -5,6 +5,7 @@ */ #include +#include /* Allow platforms to override the log prefix string */ #pragma weak plat_log_get_prefix From 6336b07ad25cb05ca75f5a465d816af7956e0a59 Mon Sep 17 00:00:00 2001 From: Yann Gautier Date: Mon, 10 Dec 2018 18:08:53 +0100 Subject: [PATCH 4/4] Makefile: add a possibility to disable -Werror Setting E=0 in the make command line disables -Werror in CPPFLAGS. Signed-off-by: Yann Gautier --- Makefile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 5841345eb..6f14825c7 100644 --- a/Makefile +++ b/Makefile @@ -226,8 +226,12 @@ else ifeq (${W},3) WARNINGS := $(WARNING1) $(WARNING2) $(WARNING3) endif +ifneq (${E},0) +ERRORS := -Werror +endif + CPPFLAGS = ${DEFINES} ${INCLUDES} ${MBEDTLS_INC} -nostdinc \ - -Wmissing-include-dirs -Werror $(WARNINGS) + -Wmissing-include-dirs $(ERRORS) $(WARNINGS) ASFLAGS += $(CPPFLAGS) $(ASFLAGS_$(ARCH)) \ -D__ASSEMBLY__ -ffreestanding \ -Wa,--fatal-warnings