Skip to content

Commit 306fd9b

Browse files
authored
Fix -Wsign-compare warning
Reported by Chromium after 2ebbe0d
1 parent f8e494f commit 306fd9b

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/time_zone_lookup.cc

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@
5454
#endif // __has_include
5555
#endif // _WIN32
5656

57+
#include <array>
58+
#include <cstdint>
5759
#include <cstdlib>
5860
#include <cstring>
5961
#include <string>
@@ -115,22 +117,22 @@ std::string win32_local_time_zone() {
115117
return "";
116118
}
117119

118-
UChar buffer[128];
120+
std::array<UChar, 128> buffer;
119121
UErrorCode status = U_ZERO_ERROR;
120122
const auto num_chars_in_buffer = ucal_getTimeZoneIDForWindowsIDFunc(
121123
reinterpret_cast<const UChar*>(info.TimeZoneKeyName), -1, nullptr,
122-
buffer, ARRAYSIZE(buffer), &status);
124+
buffer.data(), static_cast<int32_t>(buffer.size()), &status);
123125
if (status != U_ZERO_ERROR || num_chars_in_buffer <= 0 ||
124-
num_chars_in_buffer > ARRAYSIZE(buffer)) {
126+
num_chars_in_buffer > static_cast<int32_t>(buffer.size())) {
125127
return "";
126128
}
127129

128130
const int num_bytes_in_utf8 = ::WideCharToMultiByte(
129-
CP_UTF8, 0, reinterpret_cast<const wchar_t*>(buffer),
131+
CP_UTF8, 0, reinterpret_cast<const wchar_t*>(buffer.data()),
130132
static_cast<int>(num_chars_in_buffer), nullptr, 0, nullptr, nullptr);
131133
std::string local_time_str;
132134
local_time_str.resize(static_cast<size_t>(num_bytes_in_utf8));
133-
::WideCharToMultiByte(CP_UTF8, 0, reinterpret_cast<const wchar_t*>(buffer),
135+
::WideCharToMultiByte(CP_UTF8, 0, reinterpret_cast<const wchar_t*>(buffer.data()),
134136
static_cast<int>(num_chars_in_buffer),
135137
&local_time_str[0], num_bytes_in_utf8, nullptr,
136138
nullptr);

0 commit comments

Comments
 (0)