From 16e738ece2aa6fcc675fb3f0bd41453feaf979ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Lam?= Date: Fri, 5 Nov 2021 15:54:55 +0100 Subject: [PATCH] stratosphere: fix call to non-constexpr strlen in constexpr function strlen being constexpr is a non-compliant GCC extension; Clang explicitly rejects it: https://reviews.llvm.org/D23692 --- .../include/stratosphere/settings/settings_types.hpp | 8 ++------ .../libstratosphere/include/stratosphere/sm/sm_types.hpp | 4 ++-- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/libraries/libstratosphere/include/stratosphere/settings/settings_types.hpp b/libraries/libstratosphere/include/stratosphere/settings/settings_types.hpp index 247063ab4..a22adcad0 100644 --- a/libraries/libstratosphere/include/stratosphere/settings/settings_types.hpp +++ b/libraries/libstratosphere/include/stratosphere/settings/settings_types.hpp @@ -62,18 +62,14 @@ namespace ams::settings { char name[MaxLength]; - static constexpr LanguageCode Encode(const char *name, size_t name_size) { + static constexpr LanguageCode Encode(util::string_view name) { LanguageCode out{}; - for (size_t i = 0; i < MaxLength && i < name_size; i++) { + for (size_t i = 0; i < MaxLength && i < name.size(); i++) { out.name[i] = name[i]; } return out; } - static constexpr LanguageCode Encode(const char *name) { - return Encode(name, std::strlen(name)); - } - template static constexpr inline LanguageCode EncodeLanguage = [] { if constexpr (false) { /* ... */ } diff --git a/libraries/libstratosphere/include/stratosphere/sm/sm_types.hpp b/libraries/libstratosphere/include/stratosphere/sm/sm_types.hpp index f91546371..675802be1 100644 --- a/libraries/libstratosphere/include/stratosphere/sm/sm_types.hpp +++ b/libraries/libstratosphere/include/stratosphere/sm/sm_types.hpp @@ -40,8 +40,8 @@ namespace ams::sm { return out; } - static constexpr ServiceName Encode(const char *name) { - return Encode(name, std::strlen(name)); + static constexpr ServiceName Encode(util::string_view name) { + return Encode(name.data(), name.size()); } };