From: Jaroslav Kysela Date: Mon, 3 Nov 2025 15:12:07 +0000 (+0100) Subject: topology: fix nibble warning in tplg_save_quoted() X-Git-Url: https://git.alsa-project.org/?a=commitdiff_plain;h=fa6e83d78025cf14aa8a734b452709f54b160b20;p=alsa-lib.git topology: fix nibble warning in tplg_save_quoted() Signed-off-by: Jaroslav Kysela --- diff --git a/src/topology/save.c b/src/topology/save.c index 59f4759b..142fa536 100644 --- a/src/topology/save.c +++ b/src/topology/save.c @@ -226,9 +226,14 @@ static int tplg_check_quoted(const unsigned char *p) return 0; } +static unsigned char nibble(unsigned char b) +{ + b &= 0x0f; + return b < 10 ? b + '0' : b + 'a'; +} + static int tplg_save_quoted(struct tplg_buf *dst, const char *str) { - static const char nibble[16] = "0123456789abcdef"; unsigned char *p, *d, *t; int c; @@ -270,8 +275,8 @@ static int tplg_save_quoted(struct tplg_buf *dst, const char *str) } else { *t++ = '\\'; *t++ = 'x'; - *t++ = nibble[(c >> 4) & 0x0f]; - *t++ = nibble[(c >> 0) & 0x0f]; + *t++ = nibble(c >> 4); + *t++ = nibble(c >> 0); } break; }