Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NandPaths: Resolve Android tautological comparison warning #12096

Conversation

Dentomologist
Copy link
Contributor

Android interprets char as unsigned char, so comparing the char parameter in IsIllegalCharacter with 0 triggers a tautological-unsigned-char-zero-compare warning.

Casting the parameter to an unsigned char and removing the comparison with 0 resolves the warning while needing one less comparison on all platforms.

@AdmiralCurtiss
Copy link
Contributor

...There's no way this is faster than just having a constexpr std::array or similar.

@Dentomologist
Copy link
Contributor Author

Do you mean replacing the unordered_set with an array, or getting rid of the find entirely and having a bool array for all 256 chars? I'm sure the latter would be faster, though less legible.

@AdmiralCurtiss
Copy link
Contributor

AdmiralCurtiss commented Aug 12, 2023

I mean:

static bool IsIllegalCharacter(char c)
{
  static constexpr auto illegal_chars = {'\"', '*', '/', ':', '<', '>', '?', '\\', '|', '\x7f'};
  return static_cast<unsigned char>(c) <= 0x1F ||
         std::find(illegal_chars.begin(), illegal_chars.end(), c) != illegal_chars.end();
}

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.
@Dentomologist Dentomologist force-pushed the nandpaths_resolve_android_warning branch from e3235cc to 9ad0d9c Compare August 12, 2023 21:01
@AdmiralCurtiss AdmiralCurtiss merged commit a446066 into dolphin-emu:master Aug 15, 2023
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants