Skip to content

Commit e07727a

Browse files
committed
Allocate hex map with the trailing NULL
Compilers usually warns or errors on such allocations. This would require special compiler parameters or attribute to silence it. Unfortunately, it is compiler specific, e.g. with gcc one could use "__attribute__ ((nonstring))" or with C23 just "[[nonstring]]" or gcc parameter "-Wno-error=unterminated-string-initialization". With other compilers it's different. So do not over-complicate things and allocate it just one more byte longer with the dummy NULL which should silence most of the compilers. It's static allocation, just one byte, the overhead should be negligible. Signed-off-by: Jaroslav Škarvada <jskarvad@redhat.com>
1 parent 6c0ed39 commit e07727a

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

lib/util/hex.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ hidrd_hex_buf_from_str(void *buf,
8484
char *
8585
hidrd_hex_buf_to_str(const void *buf, size_t size)
8686
{
87-
static const char map[16] = "0123456789ABCDEF";
87+
static const char map[17] = "0123456789ABCDEF";
8888
const uint8_t *bbuf = (const uint8_t *)buf;
8989
char *str;
9090
char *p;

0 commit comments

Comments
 (0)