This is an archive of the discontinued LLVM Phabricator instance.

cfi: fix more -Wformat warnings
ClosedPublic

Authored by dim on Nov 23 2021, 12:13 PM.

Details

Summary

Building cfi with recent clang on a 64-bit system results in the
following warnings:

compiler-rt/lib/cfi/cfi.cpp:233:64: warning: format specifies type 'void *' but the argument has type '__sanitizer::uptr' (aka 'unsigned long') [-Wformat]
    VReport(1, "Can not handle: symtab > strtab (%p > %zx)\n", symtab, strtab);
                                                 ~~            ^~~~~~
                                                 %lu
compiler-rt/lib/sanitizer_common/sanitizer_common.h:231:46: note: expanded from macro 'VReport'
    if ((uptr)Verbosity() >= (level)) Report(__VA_ARGS__); \
                                             ^~~~~~~~~~~
compiler-rt/lib/cfi/cfi.cpp:253:59: warning: format specifies type 'void *' but the argument has type '__sanitizer::uptr' (aka 'unsigned long') [-Wformat]
    VReport(1, "Can not handle: symtab %p, strtab %zx\n", symtab, strtab);
                                       ~~                 ^~~~~~
                                       %lu
compiler-rt/lib/sanitizer_common/sanitizer_common.h:231:46: note: expanded from macro 'VReport'
    if ((uptr)Verbosity() >= (level)) Report(__VA_ARGS__); \
                                             ^~~~~~~~~~~

Since __sanitizer::uptr has the same size as size_t, consistently
use %z as a printf specifier.

Diff Detail

Event Timeline

dim requested review of this revision.Nov 23 2021, 12:13 PM
dim created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptNov 23 2021, 12:13 PM
Herald added a subscriber: Restricted Project. · View Herald Transcript
vitalybuka accepted this revision.Nov 23 2021, 8:28 PM
This revision is now accepted and ready to land.Nov 23 2021, 8:28 PM
This revision was automatically updated to reflect the committed changes.