From 25bb6131240b46b11243cfa447b2016607b6d4ff Mon Sep 17 00:00:00 2001 From: Michael Vetter Date: Tue, 19 Nov 2019 15:08:29 +0100 Subject: [PATCH] src: Always return a value from non void function elide() (#760) elide() needs to always return std:string. We cover all cases because our switch contains all current possibilities for ElideMode. But the compiler will still warn/error on this, depending on system configuration. I would like to add a `return "";` or `return str;` or add a `default:` case to the switch to silence this compiler complaint. Regards https://github.com/CoatiSoftware/Sourcetrail/issues/758 --- src/lib_utility/utility/utilityString.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/lib_utility/utility/utilityString.cpp b/src/lib_utility/utility/utilityString.cpp index c1ae490a..807fef27 100644 --- a/src/lib_utility/utility/utilityString.cpp +++ b/src/lib_utility/utility/utilityString.cpp @@ -580,6 +580,8 @@ std::string elide(const std::string& str, ElideMode mode, size_t size) case ELIDE_RIGHT: return str.substr(0, size - 3) + "..."; } + + return ""; } std::wstring elide(const std::wstring& str, ElideMode mode, size_t size) @@ -599,6 +601,8 @@ std::wstring elide(const std::wstring& str, ElideMode mode, size_t size) case ELIDE_RIGHT: return str.substr(0, size - 3) + L"..."; } + + return ""; } std::wstring convertWhiteSpacesToSingleSpaces(const std::wstring& str)