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

Explicitly truncate log entries to silence gcc #319

Merged
merged 1 commit into from Apr 6, 2021
Merged

Conversation

martelletto
Copy link
Contributor

@martelletto martelletto commented Apr 5, 2021

log.c's do_log() contains a silent (and harmless) snprintf() truncation. This truncation triggers gcc's -Wformat-truncation when combined with -O3 -D_FORTIFY_SOURCE=2 and glibc headers, as reported in #318; -O3 is enabled by CMake on CMAKE_BUILD_TYPE=Release builds, while we set -D_FORTIFY_SOURCE=2 on CMAKE_BUILD_TYPE=Release builds. This PR embeds the truncation in the format string, making it explicit and suppressing the warning. I haven't checked why the warning does not happen with -O2.

Edit: accuracy

@kongeo kongeo merged commit 8edb9a2 into master Apr 6, 2021
@kongeo kongeo deleted the gcc-snprintf-blues branch April 6, 2021 08:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants