[Libreoffice-commits] core.git: include/rtl

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Fri Aug 31 13:02:30 UTC 2018


 include/rtl/stringutils.hxx |   23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

New commits:
commit 514db965c803c24dc0f21b95740d7f7230818d94
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Fri Aug 24 11:20:27 2018 +0100
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Fri Aug 31 15:02:05 2018 +0200

    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 at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

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> {


More information about the Libreoffice-commits mailing list