Commit 2f5c6c3e authored by Sean Cannella's avatar Sean Cannella Committed by dcsommer

Really fix the clang warning in Format-inl.h

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
parent 9faada6d
......@@ -313,8 +313,12 @@ void formatString(StringPiece val, FormatArg& arg, FormatCallback& cb) {
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 &&
val.size() > arg.precision) {
val.size() > static_cast<size_t>(arg.precision)) {
val.reset(val.data(), arg.precision);
}
......@@ -331,7 +335,8 @@ void formatString(StringPiece val, FormatArg& arg, FormatCallback& cb) {
};
int padRemaining = 0;
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));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment