Skip to content

Commit

Permalink
logger: convert: Fix compile time error with newer toolchain
Browse files Browse the repository at this point in the history
Using Compiler version: aarch64-poky-linux-gcc (GCC) 13.2.0
we get the following error:

tools/logger/convert.c: In function 'convert':
tools/logger/convert.c:357:34: error: '%*s' directive output between 4294967264 and 4294967284 bytes exceeds 'INT_MAX' [-Werror=format-overflow=]
|   357 |                 fprintf(out_fd, "%*s(us)%*s  ", -ts_width, " TIMESTAMP", ts_width, "DELTA");
|       |                                  ^~~                       ~~~~~~~~~~~~
| In file included from /opt/builds/OBNand/build/tmp/work/armv8a-poky-linux/sof-tools/2.8.0/recipe-sysroot/usr/include/stdio.h:964,
|                  from /opt/builds/OBNand/build/tmp/work/armv8a-poky-linux/sof-tools/2.8.0/git/tools/logger/convert.h:13,
|                  from /opt/builds/OBNand/build/tmp/work/armv8a-poky-linux/sof-tools/2.8.0/git/tools/logger/convert.c:21:
| In function 'fprintf',

Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com>
Signed-off-by: Marc Herbert <marc.herbert@intel.com>
(cherry picked from commit ff9343a)
  • Loading branch information
marc-hb authored and kv2019i committed Jan 25, 2024
1 parent 8c52163 commit 956b370
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions tools/logger/convert.c
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ static double to_usecs(uint64_t time)
}

/** Justified timestamp width for printf format string */
static unsigned int timestamp_width(unsigned int precision)
static uint8_t timestamp_width(uint8_t precision)
{
/* 64bits yields less than 20 digits precision. As reported by
* gcc 9.3, this avoids a very long precision causing snprintf()
Expand Down Expand Up @@ -352,7 +352,7 @@ static inline void print_table_header(void)
}

if (global_config->time_precision >= 0) {
const unsigned int ts_width = timestamp_width(global_config->time_precision);
const uint8_t ts_width = timestamp_width(global_config->time_precision);

fprintf(out_fd, "%*s(us)%*s ", -ts_width, " TIMESTAMP", ts_width, "DELTA");
}
Expand Down
2 changes: 1 addition & 1 deletion tools/logger/convert.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ struct convert_config {
int dump_ldc;
int hide_location;
int relative_timestamps;
int time_precision;
uint8_t time_precision;
struct snd_sof_uids_header *uids_dict;
struct snd_sof_logs_header *logs_header;
};
Expand Down

0 comments on commit 956b370

Please sign in to comment.