Skip to content

Commit

Permalink
Fixed unterminated string initialization
Browse files Browse the repository at this point in the history
Backport of: #1030
Relates to: https://bugzilla.redhat.com/show_bug.cgi?id=2339937

gcc v15+ will add the static check for unterminated string initialization
as 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 <mengel@redhat.com>
  • Loading branch information
engelmi authored and mkemel committed Jan 30, 2025
1 parent d5230fe commit 17a6603
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/libbluechi/bus/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -315,10 +315,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) {

Expand Down

0 comments on commit 17a6603

Please sign in to comment.