[compiler-rt] 187d997 - cfi: fix more -Wformat warnings

Dimitry Andric via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 24 12:48:37 PST 2021


Author: Dimitry Andric
Date: 2021-11-24T21:48:17+01:00
New Revision: 187d9979f22e9e285d501b53c0978c1e80856fa1

URL: https://github.com/llvm/llvm-project/commit/187d9979f22e9e285d501b53c0978c1e80856fa1
DIFF: https://github.com/llvm/llvm-project/commit/187d9979f22e9e285d501b53c0978c1e80856fa1.diff

LOG: cfi: fix more -Wformat warnings

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.

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D114466

Added: 
    

Modified: 
    compiler-rt/lib/cfi/cfi.cpp

Removed: 
    


################################################################################
diff  --git a/compiler-rt/lib/cfi/cfi.cpp b/compiler-rt/lib/cfi/cfi.cpp
index 95853208f951e..65a10c999cc6b 100644
--- a/compiler-rt/lib/cfi/cfi.cpp
+++ b/compiler-rt/lib/cfi/cfi.cpp
@@ -230,7 +230,7 @@ uptr find_cfi_check_in_dso(dl_phdr_info *info) {
   }
 
   if (symtab > strtab) {
-    VReport(1, "Can not handle: symtab > strtab (%p > %zx)\n", symtab, strtab);
+    VReport(1, "Can not handle: symtab > strtab (%zx > %zx)\n", symtab, strtab);
     return 0;
   }
 
@@ -250,7 +250,7 @@ uptr find_cfi_check_in_dso(dl_phdr_info *info) {
   if (phdr_idx == info->dlpi_phnum) {
     // Nope, either 
diff erent segments or just bogus pointers.
     // Can not handle this.
-    VReport(1, "Can not handle: symtab %p, strtab %zx\n", symtab, strtab);
+    VReport(1, "Can not handle: symtab %zx, strtab %zx\n", symtab, strtab);
     return 0;
   }
 


        


More information about the llvm-commits mailing list