From ab25cd2c8baa4664870e3f3bb7adacced81d8353 Mon Sep 17 00:00:00 2001 From: vitaut Date: Wed, 21 Oct 2015 08:30:10 -0700 Subject: [PATCH] Suppress a bogus coverity warning --- format.cc | 2 +- test/format-impl-test.cc | 4 ++-- test/posix-test.cc | 4 +++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/format.cc b/format.cc index 1510339d..07a2226f 100644 --- a/format.cc +++ b/format.cc @@ -140,7 +140,7 @@ template <> struct IntChecker { template static bool fits_in_int(T value) { - return value >= INT_MIN && value <= INT_MAX; + return internal::check(value >= INT_MIN) && value <= INT_MAX; } }; diff --git a/test/format-impl-test.cc b/test/format-impl-test.cc index ec09e6e2..dbf1f580 100644 --- a/test/format-impl-test.cc +++ b/test/format-impl-test.cc @@ -61,10 +61,10 @@ TEST(FormatTest, StrError) { EXPECT_ASSERT(fmt::safe_strerror(EDOM, message = 0, 0), "invalid buffer"); EXPECT_ASSERT(fmt::safe_strerror(EDOM, message = buffer, 0), "invalid buffer"); buffer[0] = 'x'; -#ifdef _GNU_SOURCE +#if defined(_GNU_SOURCE) && !defined(__COVERITY__) // Use invalid error code to make sure that safe_strerror returns an error // message in the buffer rather than a pointer to a static string. - volatile int error_code = -1; + int error_code = -1; #else int error_code = EDOM; #endif diff --git a/test/posix-test.cc b/test/posix-test.cc index d38c952b..7dd0dbb0 100644 --- a/test/posix-test.cc +++ b/test/posix-test.cc @@ -326,11 +326,13 @@ TEST(FileTest, Dup) { EXPECT_EQ(FILE_CONTENT, read(copy, std::strlen(FILE_CONTENT))); } +#ifndef __COVERITY__ TEST(FileTest, DupError) { - volatile int value = -1; + int value = -1; EXPECT_SYSTEM_ERROR_NOASSERT(File::dup(value), EBADF, "cannot duplicate file descriptor -1"); } +#endif TEST(FileTest, Dup2) { File f = open_file();