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

Fix compiler warnings for gcc & clang #52

Merged
merged 1 commit into from
Dec 23, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions include/uuid.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@ namespace uuids
constexpr inline unsigned char hex2char(TChar const ch)
{
if (ch >= static_cast<TChar>('0') && ch <= static_cast<TChar>('9'))
return ch - static_cast<TChar>('0');
return static_cast<unsigned char>(ch - static_cast<TChar>('0'));
if (ch >= static_cast<TChar>('a') && ch <= static_cast<TChar>('f'))
return 10 + ch - static_cast<TChar>('a');
return static_cast<unsigned char>(10 + ch - static_cast<TChar>('a'));
if (ch >= static_cast<TChar>('A') && ch <= static_cast<TChar>('F'))
return 10 + ch - static_cast<TChar>('A');
return static_cast<unsigned char>(10 + ch - static_cast<TChar>('A'));
return 0;
}

Expand Down Expand Up @@ -418,7 +418,7 @@ namespace uuids
{
auto str = detail::to_string_view(in_str);
bool firstDigit = true;
int hasBraces = 0;
size_t hasBraces = 0;
size_t index = 0;

if (str.empty())
Expand Down Expand Up @@ -462,7 +462,7 @@ namespace uuids
{
auto str = detail::to_string_view(in_str);
bool firstDigit = true;
int hasBraces = 0;
size_t hasBraces = 0;
size_t index = 0;

std::array<uint8_t, 16> data{ { 0 } };
Expand All @@ -485,12 +485,13 @@ namespace uuids

if (firstDigit)
{
data[index] = detail::hex2char(str[i]) << 4;
data[index] = static_cast<uint8_t>(detail::hex2char(str[i]) << 4);
firstDigit = false;
}
else
{
data[index++] |= detail::hex2char(str[i]);
data[index] = static_cast<uint8_t>(data[index] | detail::hex2char(str[i]));
index++;
firstDigit = true;
}
}
Expand Down