Commit 4be80873 authored by Sean Cannella's avatar Sean Cannella Committed by dcsommer

Address clang sign warning in Format-inl.h

Summary:
This has been bothering me for a while when I've been trying to
verify builds with clang. This generates a ton of spew and the current
code can't actually handle non-default negatives so let's just throw if
we see one.

Test Plan: fbmake runtests

Reviewed By: meyering@fb.com

Subscribers: mathieubaudet, njormrod, folly-diffs@, bmatheny, benyluo, shikong, kmdent, fma, ranjeeth, subodh

FB internal diff: D1643881

Signature: t1:1643881:1414523777:085035ce8c280fbd6481b2ce0354b53b96fdc50e
parent b8c06335
...@@ -306,6 +306,13 @@ namespace format_value { ...@@ -306,6 +306,13 @@ namespace format_value {
template <class FormatCallback> template <class FormatCallback>
void formatString(StringPiece val, FormatArg& arg, FormatCallback& cb) { void formatString(StringPiece val, FormatArg& arg, FormatCallback& cb) {
if (arg.width != FormatArg::kDefaultWidth && arg.width < 0) {
throw BadFormatArg("folly::format: invalid width");
}
if (arg.precision != FormatArg::kDefaultPrecision && arg.precision < 0) {
throw BadFormatArg("folly::format: invalid precision");
}
if (arg.precision != FormatArg::kDefaultPrecision && if (arg.precision != FormatArg::kDefaultPrecision &&
val.size() > arg.precision) { val.size() > arg.precision) {
val.reset(val.data(), arg.precision); val.reset(val.data(), arg.precision);
......
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