Skip to content

Commit

Permalink
logger: increase time_fmt[] size to avoid a gcc warning.
Browse files Browse the repository at this point in the history
gcc does not know that we already filtered unreasonable precision
values.

Increase the size of the temporary string from 32 bytes to 64
bytes. We're running on the host, memory is cheap.

Fixes commit d6f6a45 ("logger: fix column and header alignments")
For some reason CMake uses -Werror=format-truncation only in Release
mode.

Avoids the following warning:

```
sof/tools/logger/convert.c: In function ‘fetch_entry’:
sof/tools/logger/convert.c:514:27: error: ‘%d’ directive output may be
  truncated writing between 1 and 10 bytes into a region of size
  between 0 and 18 [-Werror=format-truncation=]

  514 |      "%%s[%%%d.%df] (%%%d.%df)%%s ",
      |                           ^~

sof/tools/logger/convert.c:514:6: note: directive argument in the
       range [0, 2147483647]
  514 |      "%%s[%%%d.%df] (%%%d.%df)%%s ",
      |      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

In file included from /usr/include/stdio.h:867,
                 from sof/tools/logger/convert.h:13,
                 from sof/tools/logger/convert.c:21:
/usr/include/x86_64-linux-gnu/bits/stdio2.h:67:10:

   note: ‘__builtin___snprintf_chk’ output between 21 and 59 bytes into
   a destination of size 32

   67 | return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
      |        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   68 |      __bos (__s), __fmt, __va_arg_pack ());
      |      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

cc1: all warnings being treated as errors
```

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
  • Loading branch information
marc-hb committed May 22, 2021
1 parent 0a1029c commit 825cf48
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion tools/logger/convert.c
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ static void print_entry_params(const struct log_entry_header *dma_log,
char ids[TRACE_MAX_IDS_STR];
float dt = to_usecs(dma_log->timestamp - last_timestamp);
struct proc_ldc_entry proc_entry;
static char time_fmt[32];
static char time_fmt[64];
int ret;

if (raw_output)
Expand Down

0 comments on commit 825cf48

Please sign in to comment.