summaryrefslogtreecommitdiff
path: root/include/rtl/stringutils.hxx
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2018-08-24 11:20:27 +0100
committerCaolán McNamara <caolanm@redhat.com>2018-08-31 15:02:05 +0200
commit514db965c803c24dc0f21b95740d7f7230818d94 (patch)
tree861d7784237fb3d171597c3134b36077fee206e7 /include/rtl/stringutils.hxx
parent239e65474fe03dd2f9c6ca7e9ccc4554c20297b1 (diff)
coverity#1438473 silence Logically dead code
Change-Id: I10b3821311515bb5148dab698f07d902c5c73100 Reviewed-on: https://gerrit.libreoffice.org/59822 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'include/rtl/stringutils.hxx')
-rw-r--r--include/rtl/stringutils.hxx23
1 files changed, 23 insertions, 0 deletions
diff --git a/include/rtl/stringutils.hxx b/include/rtl/stringutils.hxx
index 53f7554ee132..e9aacbc3becb 100644
--- a/include/rtl/stringutils.hxx
+++ b/include/rtl/stringutils.hxx
@@ -184,6 +184,29 @@ struct ConstCharArrayDetector< const char[ N ], T >
#endif
static char const * toPointer(char const (& literal)[N]) { return literal; }
};
+
+#if defined(__COVERITY__)
+//to silence over zealous warnings that the loop is logically dead
+//for the single char case
+template< typename T >
+struct ConstCharArrayDetector< const char[ 1 ], T >
+{
+ typedef T Type;
+ static const std::size_t length = 0;
+ static const bool ok = true;
+#if defined LIBO_INTERNAL_ONLY && HAVE_CXX14_CONSTEXPR
+ constexpr
+#endif
+ static bool isValid(char const (& literal)[1]) {
+ return literal[0] == '\0';
+ }
+#if defined LIBO_INTERNAL_ONLY
+ constexpr
+#endif
+ static char const * toPointer(char const (& literal)[1]) { return literal; }
+};
+#endif
+
#if defined LIBO_INTERNAL_ONLY
template<std::size_t N, typename T>
struct ConstCharArrayDetector<sal_Unicode const [N], T> {