From 9955a06dbd7effb451a67e09720222fac8ba9601 Mon Sep 17 00:00:00 2001 From: Dentomologist Date: Sat, 12 Aug 2023 12:53:57 -0700 Subject: [PATCH 1/2] NandPaths: Resolve Android tautological comparison warning Android interprets char as unsigned char, so comparing with 0 triggers a tautological-unsigned-char-zero-compare warning. Casting c to an unsigned char and removing the comparison with 0 resolves the warning while needing one less comparison on all platforms. --- Source/Core/Common/NandPaths.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Core/Common/NandPaths.cpp b/Source/Core/Common/NandPaths.cpp index c9217565bb..e6f2d2a88b 100644 --- a/Source/Core/Common/NandPaths.cpp +++ b/Source/Core/Common/NandPaths.cpp @@ -107,7 +107,7 @@ static bool IsIllegalCharacter(char c) { static const std::unordered_set illegal_chars = {'\"', '*', '/', ':', '<', '>', '?', '\\', '|', '\x7f'}; - return (c >= 0 && c <= 0x1F) || illegal_chars.find(c) != illegal_chars.end(); + return static_cast(c) <= 0x1F || illegal_chars.find(c) != illegal_chars.end(); } std::string EscapeFileName(const std::string& filename) From 9ad0d9ca6adbe94c9f60b85042789432950395ce Mon Sep 17 00:00:00 2001 From: Dentomologist Date: Sat, 12 Aug 2023 13:55:18 -0700 Subject: [PATCH 2/2] NandPaths: Use initializer_list instead of unordered_set --- Source/Core/Common/NandPaths.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Source/Core/Common/NandPaths.cpp b/Source/Core/Common/NandPaths.cpp index e6f2d2a88b..5e6aa57d70 100644 --- a/Source/Core/Common/NandPaths.cpp +++ b/Source/Core/Common/NandPaths.cpp @@ -5,7 +5,6 @@ #include #include -#include #include #include @@ -105,9 +104,9 @@ bool IsTitlePath(const std::string& path, std::optional from, u64 static bool IsIllegalCharacter(char c) { - static const std::unordered_set illegal_chars = {'\"', '*', '/', ':', '<', - '>', '?', '\\', '|', '\x7f'}; - return static_cast(c) <= 0x1F || illegal_chars.find(c) != illegal_chars.end(); + static constexpr auto illegal_chars = {'\"', '*', '/', ':', '<', '>', '?', '\\', '|', '\x7f'}; + return static_cast(c) <= 0x1F || + std::find(illegal_chars.begin(), illegal_chars.end(), c) != illegal_chars.end(); } std::string EscapeFileName(const std::string& filename)