Skip to content

Commit

Permalink
printf type correctness
Browse files Browse the repository at this point in the history
The %.*s format specifier requires an int for the maximum size, but StringRef::size is a size_t

cc @shepmaster
  • Loading branch information
Robin Kruppe committed Dec 7, 2016
1 parent 85dc08e commit f58e553
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/rustllvm/PassWrapper.cpp
Expand Up @@ -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()) {
Expand Down

0 comments on commit f58e553

Please sign in to comment.