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

Use correct printf format for uintptr_t. #48

Merged
merged 1 commit into from
Jan 2, 2021

Conversation

QuLogic
Copy link
Contributor

@QuLogic QuLogic commented Jan 2, 2021

This is fine on 64-bit systems, but warns on 32-bit systems:

trace_back_backtrace.c: In function 'cb_get_name_ip':
trace_back_backtrace.c:87:19: warning: format '%llx' expects argument of type 'long long unsigned int', but argument 3 has type 'uintptr_t' {aka 'unsigned int'} [-Wformat=]
   87 |   sprintf(ip_buf, "%.16" PRIx64, pc);
      |                   ^~~~~~         ~~
      |                                  |
      |                                  uintptr_t {aka unsigned int}

and similar for trace_back_unwind.c.

I'm not sure how portable this format macro is; if not, I can add a cast instead.

This is fine on 64-bit systems, but warns on 32-bit systems:
```
trace_back_backtrace.c: In function 'cb_get_name_ip':
trace_back_backtrace.c:87:19: warning: format '%llx' expects argument of type 'long long unsigned int', but argument 3 has type 'uintptr_t' {aka 'unsigned int'} [-Wformat=]
   87 |   sprintf(ip_buf, "%.16" PRIx64, pc);
      |                   ^~~~~~         ~~
      |                                  |
      |                                  uintptr_t {aka unsigned int}

```
and similar for `trace_back_unwind.c`.
@codecov-io
Copy link

Codecov Report

Merging #48 (1463357) into master (37071c0) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master      #48   +/-   ##
=======================================
  Coverage   85.57%   85.57%           
=======================================
  Files          13       13           
  Lines         201      201           
=======================================
  Hits          172      172           
  Misses         29       29           
Impacted Files Coverage Δ
src/trace_back_unwind.c 0.00% <ø> (ø)
src/trace_back_backtrace.c 90.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 84b075b...1463357. Read the comment docs.

@krlmlr
Copy link
Member

krlmlr commented Jan 2, 2021

Thanks!

@QuLogic QuLogic deleted the fix-printf-warning branch January 2, 2021 11:13
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 3, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants