Summary:
The previous diff added the safety check but didn't actually
remove the compiler warning. This is what I get for doing an incremental
compile.
Test Plan: fbmake clean ; fbmake dbg with clang:dev
Reviewed By: meyering@fb.com
Subscribers: trunkagent, mathieubaudet, njormrod, folly-diffs@, bmatheny, ranjeeth, subodh, kmdent, fma, benyluo
FB internal diff:
D1646519
Signature: t1:
1646519:
1414602292:
cfb908ae094caaef02e64eb2c42544fd34fa1389
throw BadFormatArg("folly::format: invalid precision");
}
throw BadFormatArg("folly::format: invalid precision");
}
+ // XXX: clang should be smart enough to not need the two static_cast<size_t>
+ // uses below given the above checks. If clang ever becomes that smart, we
+ // should remove the otherwise unnecessary warts.
+
if (arg.precision != FormatArg::kDefaultPrecision &&
if (arg.precision != FormatArg::kDefaultPrecision &&
- val.size() > arg.precision) {
+ val.size() > static_cast<size_t>(arg.precision)) {
val.reset(val.data(), arg.precision);
}
val.reset(val.data(), arg.precision);
}
- if (arg.width != FormatArg::kDefaultWidth && val.size() < arg.width) {
+ if (arg.width != FormatArg::kDefaultWidth &&
+ val.size() < static_cast<size_t>(arg.width)) {
char fill = arg.fill == FormatArg::kDefaultFill ? ' ' : arg.fill;
int padChars = static_cast<int> (arg.width - val.size());
memset(padBuf, fill, std::min(padBufSize, padChars));
char fill = arg.fill == FormatArg::kDefaultFill ? ' ' : arg.fill;
int padChars = static_cast<int> (arg.width - val.size());
memset(padBuf, fill, std::min(padBufSize, padChars));