From cd097d334e240fff61f3abb7bde4318ccfc6a46d Mon Sep 17 00:00:00 2001 From: vitaut Date: Wed, 21 Oct 2015 06:16:55 -0700 Subject: [PATCH] Workaround bogus coverity warnings --- format.cc | 6 ++++-- test/printf-test.cc | 5 ++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/format.cc b/format.cc index 84447d2f..1510339d 100644 --- a/format.cc +++ b/format.cc @@ -780,9 +780,11 @@ void fmt::BasicWriter::write_str( const StrChar *str_value = s.value; std::size_t str_size = s.size; if (str_size == 0) { - if (!str_value) + if (!str_value) { FMT_THROW(FormatError("string pointer is null")); - else if (*str_value) + return; + } + if (*str_value) str_size = std::char_traits::length(str_value); } std::size_t precision = spec.precision_; diff --git a/test/printf-test.cc b/test/printf-test.cc index 9bb9a62e..0e615740 100644 --- a/test/printf-test.cc +++ b/test/printf-test.cc @@ -337,10 +337,9 @@ void TestLength(const char *length_spec) { TestLength(length_spec, min); TestLength(length_spec, max); using fmt::internal::check; - if (check(min >= 0 || static_cast(min) > - std::numeric_limits::min())) { + fmt::LongLong long_long_min = std::numeric_limits::min(); + if (check(min >= 0) || check(static_cast(min) > long_long_min)) TestLength(length_spec, fmt::LongLong(min) - 1); - } fmt::ULongLong long_long_max = std::numeric_limits::max(); if (check(max < 0 || static_cast(max) < long_long_max)) TestLength(length_spec, fmt::LongLong(max) + 1);