about summary refs log tree commit diff
path: root/src/rustllvm/PassWrapper.cpp
diff options
context:
space:
mode:
authorRobin Kruppe <robin.kruppe@gmail.com>2016-12-07 17:02:34 +0100
committerRobin Kruppe <robin.kruppe@gmail.com>2016-12-07 17:09:34 +0100
commitf58e553001537d52e67720156f9280d122cc242d (patch)
treecb24c8b927fcd98bb2d4963b3cc8aa265d97920e /src/rustllvm/PassWrapper.cpp
parent85dc08e525622365909cdaae27f4b89179321a92 (diff)
downloadrust-f58e553001537d52e67720156f9280d122cc242d.tar.gz
rust-f58e553001537d52e67720156f9280d122cc242d.zip
printf type correctness
The %.*s format specifier requires an int for the maximum size, but StringRef::size is a size_t

cc @shepmaster
Diffstat (limited to 'src/rustllvm/PassWrapper.cpp')
-rw-r--r--src/rustllvm/PassWrapper.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/rustllvm/PassWrapper.cpp b/src/rustllvm/PassWrapper.cpp
index d1eb261abd3..c45d1c2d088 100644
--- a/src/rustllvm/PassWrapper.cpp
+++ b/src/rustllvm/PassWrapper.cpp
@@ -533,8 +533,11 @@ LLVMRustPrintPasses() {
             StringRef PassArg = info->getPassArgument();
             StringRef PassName = info->getPassName();
             if (!PassArg.empty()) {
-                printf("%15.*s - %.*s\n", PassArg.size(), PassArg.data(),
-                       PassName.size(), PassName.data());
+                // These unsigned->signed casts could theoretically overflow, but
+                // realistically never will (and even if, the result is implementation
+                // defined rather plain UB).
+                printf("%15.*s - %.*s\n", (int)PassArg.size(), PassArg.data(),
+                       (int)PassName.size(), PassName.data());
             }
 #else
             if (info->getPassArgument() && *info->getPassArgument()) {