From dc40042322fecd0c3eec90fcf4528f211ee2fa58 Mon Sep 17 00:00:00 2001 From: Martin Pietryka Date: Wed, 4 Dec 2019 07:25:51 +0100 Subject: [PATCH] include: sbi_platform: fix compilation for GCC-9 GCC-9 will throw a warning when using the %s format specifier with a possible NULL parameter and since -Werror is used, the compilation breaks for GCC-9. In function 'sbi_boot_prints', inlined from 'init_coldboot' at /opensbi/lib/sbi/sbi_init.c:107:3, inlined from 'sbi_init' at /opensbi/lib/sbi/sbi_init.c:189:3: /opensbi/lib/sbi/sbi_init.c:56:2: error: '%s' directive argument is null [-Werror=format-overflow=] 56 | sbi_printf("Platform Name : %s\n", sbi_platform_name(plat)); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ cc1: all warnings being treated as errors This is one way to fix this, currently there is nothing in the tree checking for `sbi_platfrom_name() == NULL` so we can just return "Unknown" instead of NULL on failure. Signed-off-by: Martin Pietryka Reviewed-by: Anup Patel Tested-by: David Abdurachmanov --- include/sbi/sbi_platform.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/sbi/sbi_platform.h b/include/sbi/sbi_platform.h index beb2f237..010328eb 100644 --- a/include/sbi/sbi_platform.h +++ b/include/sbi/sbi_platform.h @@ -200,13 +200,13 @@ struct sbi_platform { * * @param plat pointer to struct sbi_platform * - * @return pointer to platform name on success and NULL on failure + * @return pointer to platform name on success and "Unknown" on failure */ static inline const char *sbi_platform_name(const struct sbi_platform *plat) { if (plat) return plat->name; - return NULL; + return "Unknown"; } /**