aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorMartin Pietryka <martin@pietryka.at>2019-12-04 07:25:51 +0100
committerAnup Patel <anup@brainfault.org>2019-12-06 03:15:50 +0530
commitdc40042322fecd0c3eec90fcf4528f211ee2fa58 (patch)
treefd205e9ec95deb59b62be6ddbe0ff6042dbad32c /include
parent813f7f4c250af9f7c9546f64778e9b35bb7d7dcb (diff)
downloadopensbi-dc40042322fecd0c3eec90fcf4528f211ee2fa58.zip
opensbi-dc40042322fecd0c3eec90fcf4528f211ee2fa58.tar.gz
opensbi-dc40042322fecd0c3eec90fcf4528f211ee2fa58.tar.bz2
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 <redacted>/opensbi/lib/sbi/sbi_init.c:107:3, inlined from 'sbi_init' at <redacted>/opensbi/lib/sbi/sbi_init.c:189:3: <redacted>/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 <martin@pietryka.at> Reviewed-by: Anup Patel <anup.patel@wdc.com> Tested-by: David Abdurachmanov <david.abdurachmanov@sifive.com>
Diffstat (limited to 'include')
-rw-r--r--include/sbi/sbi_platform.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/include/sbi/sbi_platform.h b/include/sbi/sbi_platform.h
index beb2f23..010328e 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";
}
/**