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

fix -Wformat issues reported by clang #349

Merged
merged 1 commit into from
Nov 9, 2021

Conversation

sebastienraillet
Copy link
Contributor

@sebastienraillet sebastienraillet commented Nov 9, 2021

Summary

This PR is about fixing compilation issues detected with clang on android 10 toolchain where -Werror and -Wformat are activated

Description

  • some previous dlt_vlog was using %lu specifier to display an uint64_t variable. However, this isn't portable as depending on the system you're targeting (32bits, 64bits, Linux, android, etc.), the uint64_t can be an unsigned long long. This prevents compilation on system where -Werror and -Wformat is activated coupled with a less tolerant compiler (e.g clang). Instead, PRIxN macros (e.g PRIu64 for uint64_t) are now used as specifier to ensure compatibility for each platforms
  • for bytes_read which is of type ssize_t, zd specifier is used as indicated in C99 standard
  • for st_size (from struct stat) which is of type off_t, POSIX says that it should be a signed integer. To be safe, we now use %jd specifier to ensure that it will fit correctly

* some previous dlt_vlog was using %lu specifier to display an uint64_t
variable. However, this isn't portable as depending on the system you're
targeting (32bits, 64bits, Linux, android, etc.), the uint64_t can be an
unsigned long long. This prevents compilation on system where -Werror
and -Wformat is activated coupled with a less tolerant compiler
(e.g clang). Instead, PRIxN macros (e.g PRIu64 for uint64_t) are now
used as specifier to ensure compatibility for each platforms
* for bytes_read which is of type ssize_t, zd specifier is used as
indicated in C99 standard
* for st_size (from struct stat) which is of type off_t, POSIX says that
it should be a signed integer. To be safe, we now use %jd specifier to
ensure that it will fit correctly
@ssugiura ssugiura merged commit ac5b124 into COVESA:master Nov 9, 2021
@sebastienraillet sebastienraillet deleted the fix_printf_format branch November 9, 2021 08:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants