Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Failure to compile tools/logger/convert.c #8766

Closed
dbaluta opened this issue Jan 22, 2024 · 3 comments
Closed

[BUG] Failure to compile tools/logger/convert.c #8766

dbaluta opened this issue Jan 22, 2024 · 3 comments
Assignees
Labels
bug Something isn't working as expected

Comments

@dbaluta
Copy link
Collaborator

dbaluta commented Jan 22, 2024

Describe the bug

Compiling the sof-logger for aarch64 we get the following warnings which gets translated into an error and compilation stops:

-- Build files have been written to: /opt/builds/OBNand/build/tmp/work/armv8a-poky-linux/sof-tools/2.8.0/git/tools/sof-tools
| [ 20%] Building C object logger/CMakeFiles/sof-logger.dir/convert.c.o
| /opt/builds/OBNand/build/tmp/work/armv8a-poky-linux/sof-tools/2.8.0/git/tools/logger/convert.c: In function 'convert':
| /opt/builds/OBNand/build/tmp/work/armv8a-poky-linux/sof-tools/2.8.0/git/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',
|     inlined from 'print_table_header' at /opt/builds/OBNand/build/tmp/work/armv8a-poky-linux/sof-tools/2.8.0/git/tools/logger/convert.c:357:3,
|     inlined from 'logger_read' at /opt/builds/OBNand/build/tmp/work/armv8a-poky-linux/sof-tools/2.8.0/git/tools/logger/convert.c:846:3,
|     inlined from 'convert' at /opt/builds/OBNand/build/tmp/work/armv8a-poky-linux/sof-tools/2.8.0/git/tools/logger/convert.c:1151:8:
| /opt/builds/OBNand/build/tmp/work/armv8a-poky-linux/sof-tools/2.8.0/recipe-sysroot/usr/include/bits/stdio2.h:79:10: note: '__fprintf_chk' output between 4294967283 and 4294967323 bytes
|    79 |   return __fprintf_chk (__stream, __USE_FORTIFY_LEVEL - 1, __fmt,
|       |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|    80 |                         __va_arg_pack ());
|       |                         ~~~~~~~~~~~~~~~~~

Compiler version: aarch64-poky-linux-gcc (GCC) 13.2.0

Environment

  1. Branch name and commit hash of the 2 repositories: sof (firmware/topology) and linux (kernel driver).
    • SOF: 16b53b4 (main) audio: host: reload DMA buffer on non-zero partial_size

It looks like the issues was introduced by 4c905f5

commit 4c905f5234faf2cb32b0663dfd0b1c494b0a2a93
Author: Adrian Warecki <[email protected]>
Date:   Mon Sep 18 15:31:28 2023 +0200

    logger: convert: Simplified printing of a tim

@dbaluta dbaluta added the bug Something isn't working as expected label Jan 22, 2024
@marc-hb
Copy link
Collaborator

marc-hb commented Jan 22, 2024

It looks like the issues was introduced by 4c905f5

Yes but before #8216 the code was worse :-)

Can you try something like this below? (untested)

--- a/tools/logger/convert.c
+++ b/tools/logger/convert.c
@@ -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()
@@ -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");
        }
diff --git a/tools/logger/convert.h b/tools/logger/convert.h
index dcf8d0db06b7..8117e023b2f9 100644
--- a/tools/logger/convert.h
+++ b/tools/logger/convert.h
@@ -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;
 };

cc: @softwarecki

@dbaluta
Copy link
Collaborator Author

dbaluta commented Jan 23, 2024

@marc-hb this works. Feel free to ACK this PR: #8778

@marc-hb
Copy link
Collaborator

marc-hb commented Jan 25, 2024

Submitted to stable-v2.2 here: #8798

@marc-hb marc-hb closed this as completed Jan 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working as expected
Projects
None yet
Development

No branches or pull requests

3 participants