From fb27723a9f6873bf6c64483ec6eef4ec6108ef4a Mon Sep 17 00:00:00 2001 From: vitaut Date: Thu, 22 Oct 2015 07:33:01 -0700 Subject: [PATCH] Try fixing bogus coverity warnings, take n --- format.cc | 3 ++- test/gtest-extra-test.cc | 10 ++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/format.cc b/format.cc index 6caa61f1..ab22f909 100644 --- a/format.cc +++ b/format.cc @@ -140,8 +140,9 @@ template <> struct IntChecker { template static bool fits_in_int(T value) { - return internal::check(value >= INT_MIN) && value <= INT_MAX; + return value >= INT_MIN && value <= INT_MAX; } + static bool fits_in_int(int value) { return true; } }; const char RESET_COLOR[] = "\x1b[0m"; diff --git a/test/gtest-extra-test.cc b/test/gtest-extra-test.cc index f51f3cce..93a1eca3 100644 --- a/test/gtest-extra-test.cc +++ b/test/gtest-extra-test.cc @@ -42,6 +42,13 @@ using testing::internal::scoped_ptr; namespace { +std::string sanitize(const std::string &s) { + std::string result; + for (std::string::const_iterator i = s.begin(), end = s.end(); i != end; ++i) + result.push_back(*i & 0xff); + return result; +} + // Tests that assertion macros evaluate their arguments exactly once. class SingleEvaluationTest : public ::testing::Test { protected: @@ -377,8 +384,7 @@ TEST(OutputRedirectTest, RestoreAndRead) { std::fprintf(file.get(), "[[["); OutputRedirect redir(file.get()); std::fprintf(file.get(), "censored"); - // coverity[tainted_data] - EXPECT_EQ("censored", redir.restore_and_read()); + EXPECT_EQ("censored", sanitize(redir.restore_and_read())); EXPECT_EQ("", redir.restore_and_read()); std::fprintf(file.get(), "]]]"); file = BufferedFile();