From d43fab8766831be1c375f950a87a56557a192a51 Mon Sep 17 00:00:00 2001 From: Michael Engel Date: Mon, 20 Jan 2025 16:09:59 +0100 Subject: [PATCH] Ignore unterminated string initialization for hexchar gcc v15+ will add the check for unterminated string initialization as a default, thus causing the build to fail due to the hexchar function. Since this function uses the char array only for mapping an integer to a hexadecimal char, this error can be ignored. Signed-off-by: Michael Engel --- src/libbluechi/bus/utils.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/libbluechi/bus/utils.c b/src/libbluechi/bus/utils.c index e432869b1e..8f236d933c 100644 --- a/src/libbluechi/bus/utils.c +++ b/src/libbluechi/bus/utils.c @@ -250,10 +250,20 @@ int assemble_object_path_string(const char *prefix, const char *name, char **res return asprintf(res, "%s/%s", prefix, escaped); } +// Disabling -Wunterminated-string-initialization temporarily. +// hexchar uses the table array only for mapping an integer to +// a hexadecimal char, no need for it to be NULL terminated. +#if __GNUC__ >= 15 +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wunterminated-string-initialization" +#endif static char hexchar(int x) { static const char table[16] = "0123456789abcdef"; return table[(unsigned int) x % sizeof(table)]; } +#if __GNUC__ >= 15 +# pragma GCC diagnostic pop +#endif char *bus_path_escape(const char *s) {