Skip to content

Commit

Permalink
Ignore unterminated string initialization for hexchar
Browse files Browse the repository at this point in the history
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 <mengel@redhat.com>
  • Loading branch information
engelmi committed Jan 20, 2025
1 parent 5bc1b9a commit b9db02b
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/libbluechi/bus/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -250,10 +250,16 @@ 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.
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunterminated-string-initialization"
static char hexchar(int x) {
static const char table[16] = "0123456789abcdef";
return table[(unsigned int) x % sizeof(table)];
}
#pragma GCC diagnostic pop

char *bus_path_escape(const char *s) {

Expand Down

0 comments on commit b9db02b

Please sign in to comment.