Skip to content

Commit f58e553

Browse files
author
Robin Kruppe
committed
printf type correctness
The %.*s format specifier requires an int for the maximum size, but StringRef::size is a size_t cc @shepmaster
1 parent 85dc08e commit f58e553

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/rustllvm/PassWrapper.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -533,8 +533,11 @@ LLVMRustPrintPasses() {
533533
StringRef PassArg = info->getPassArgument();
534534
StringRef PassName = info->getPassName();
535535
if (!PassArg.empty()) {
536-
printf("%15.*s - %.*s\n", PassArg.size(), PassArg.data(),
537-
PassName.size(), PassName.data());
536+
// These unsigned->signed casts could theoretically overflow, but
537+
// realistically never will (and even if, the result is implementation
538+
// defined rather plain UB).
539+
printf("%15.*s - %.*s\n", (int)PassArg.size(), PassArg.data(),
540+
(int)PassName.size(), PassName.data());
538541
}
539542
#else
540543
if (info->getPassArgument() && *info->getPassArgument()) {

0 commit comments

Comments
 (0)