From 80c99760fb4363b4c9ce8bdbd16b84cbb5ac22fb Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Sat, 7 Jun 2014 07:11:34 -0700 Subject: [PATCH] Fix warnings. --- format.cc | 15 +++++++-------- test/posix-test.cc | 4 ++-- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/format.cc b/format.cc index a239bc82..ab867259 100644 --- a/format.cc +++ b/format.cc @@ -594,7 +594,7 @@ void fmt::BasicWriter::PrintfParser::Format( } writer.buffer_.append(start, s - 1); - FormatSpec spec; + FormatSpec spec(UINT_MAX); spec.align_ = ALIGN_RIGHT; // Reporting errors is delayed till the format specification is @@ -610,17 +610,15 @@ void fmt::BasicWriter::PrintfParser::Format( const char *error = 0; unsigned arg_index = 0; - bool have_width = false, have_arg_index = false; + bool have_arg_index = false; c = *s; if (c >= '0' && c <= '9') { unsigned value = internal::ParseNonnegativeInt(s, error); if (*s != '$') { if (c == '0') spec.fill_ = '0'; - if (value != 0) { - have_width = true; + if (value != 0) spec.width_ = value; - } } else { ++s; if (next_arg_index_ <= 0) { @@ -654,8 +652,9 @@ void fmt::BasicWriter::PrintfParser::Format( } int precision = -1; - switch (have_width) { - case false: { + switch (spec.width_) { + case UINT_MAX: { + spec.width_ = 0; // TODO: parse optional flags bool stop = false; do { @@ -742,7 +741,7 @@ void fmt::BasicWriter::PrintfParser::Format( break; spec.width_ = internal::ParseNonnegativeInt(s, error); } - // Fall through. + // Fall through. default: if (spec.fill_ == '0') { spec.align_ = ALIGN_NUMERIC; diff --git a/test/posix-test.cc b/test/posix-test.cc index e4eb5e2a..5c9ab023 100644 --- a/test/posix-test.cc +++ b/test/posix-test.cc @@ -188,7 +188,7 @@ TEST(FileTest, ReadRetry) { std::streamsize count = 0; EXPECT_RETRY(count = read_end.read(buffer, SIZE), read, "cannot read from file"); - EXPECT_EQ_POSIX(SIZE, count); + EXPECT_EQ_POSIX(static_cast(SIZE), count); } TEST(FileTest, WriteRetry) { @@ -200,7 +200,7 @@ TEST(FileTest, WriteRetry) { write, "cannot write to file"); write_end.close(); #ifndef _WIN32 - EXPECT_EQ(SIZE, count); + EXPECT_EQ(static_cast(SIZE), count); char buffer[SIZE + 1]; read_end.read(buffer, SIZE); buffer[SIZE] = '\0';