libsmartcols: (samples): fix format truncation warning
As this is only an example and the needed memory is not much just hardcode a large enough number. The previously computed value was wrong anyways. libsmartcols/samples/continuous.c: In function 'main': libsmartcols/samples/continuous.c:110:61: error: '%3d' directive output may be truncated writing between 3 and 11 bytes into a region of size between 0 and 7 [-Werror=format-truncation=] 110 | snprintf(timecell, timecellsz, "%f [%3d%%]", diff, | ^~~ libsmartcols/samples/continuous.c:110:25: note: 'snprintf' output between 11 and 333 bytes into a destination of size 12 110 | snprintf(timecell, timecellsz, "%f [%3d%%]", diff, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 111 | done ? 100 : (int)(diff / (TIME_PERIOD / 100.0))); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ libsmartcols/samples/continuous.c:110:61: error: '%3d' directive output may be truncated writing 3 bytes into a region of size between 0 and 7 [-Werror=format-truncation=] 110 | snprintf(timecell, timecellsz, "%f [%3d%%]", diff, | ^~~ libsmartcols/samples/continuous.c:110:25: note: 'snprintf' output between 11 and 325 bytes into a destination of size 12 110 | snprintf(timecell, timecellsz, "%f [%3d%%]", diff, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 111 | done ? 100 : (int)(diff / (TIME_PERIOD / 100.0))); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
This commit is contained in:
parent
cf652a7278
commit
d36705f402
1 changed files with 1 additions and 1 deletions
|
@ -69,7 +69,7 @@ int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
struct libscols_table *tb;
|
struct libscols_table *tb;
|
||||||
size_t i;
|
size_t i;
|
||||||
const size_t timecellsz = sizeof(stringify_value(UINT_MAX));
|
const size_t timecellsz = 500;
|
||||||
struct timeval last;
|
struct timeval last;
|
||||||
|
|
||||||
scols_init_debug(0);
|
scols_init_debug(0);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue