mirror of
https://codeberg.org/dnkl/yambar.git
synced 2025-04-19 19:25:41 +02:00
tag: explicitly initialize ‘fmt’
Fixes the following compiler warning/error: In file included from /usr/include/stdio.h:906, from ../tag.c:6: In function ‘snprintf’, inlined from ‘tags_expand_template’ at ../tag.c:708:13: /usr/include/bits/stdio2.h:54:10: error: ‘fmt’ may be used uninitialized [-Werror=maybe-uninitialized] 54 | return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 55 | __glibc_objsize (__s), __fmt, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 56 | __va_arg_pack ()); | ~~~~~~~~~~~~~~~~~ ../tag.c: In function ‘tags_expand_template’: ../tag.c:677:25: note: ‘fmt’ was declared here 677 | const char *fmt; | ^~~ cc1: all warnings being treated as errors Closes #311
This commit is contained in:
parent
5db61745a4
commit
e1fc3a0e29
1 changed files with 3 additions and 1 deletions
4
tag.c
4
tag.c
|
@ -674,7 +674,7 @@ tags_expand_template(const char *template, const struct tag_set *tags)
|
|||
const long max = tag->max(tag);
|
||||
long value = kind == VALUE_MIN ? min : max;
|
||||
|
||||
const char *fmt;
|
||||
const char *fmt = NULL;
|
||||
switch (format) {
|
||||
case FMT_DEFAULT: fmt = zero_pad ? "%0*ld" : "%*ld"; break;
|
||||
case FMT_HEX: fmt = zero_pad ? "%0*lx" : "%*lx"; break;
|
||||
|
@ -704,6 +704,8 @@ tags_expand_template(const char *template, const struct tag_set *tags)
|
|||
}
|
||||
}
|
||||
|
||||
assert(fmt != NULL);
|
||||
|
||||
char str[24];
|
||||
snprintf(str, sizeof(str), fmt, digits, value);
|
||||
sbuf_append(&formatted, str);
|
||||
|
|
Loading…
Add table
Reference in a new issue