url: Remove _itow_s()
This function appears to called only in the unit test. Remove it, and save `spanify` from wanting to apply `base::span` to its impl. Change-Id: Ie00985978d13fe9ab910f00656c2cc5365638fce Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6355895 Commit-Queue: Kalvin Lee <kdlee@chromium.org> Commit-Queue: Mike West <mkwst@chromium.org> Auto-Submit: Kalvin Lee <kdlee@chromium.org> Reviewed-by: Mike West <mkwst@chromium.org> Cr-Commit-Position: refs/heads/main@{#1433443}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
b98b5b9ad6
commit
11f21004b1
@ -369,26 +369,6 @@ int _itoa_s(int value, char* buffer, size_t size_in_chars, int radix) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _itow_s(int value, char16_t* buffer, size_t size_in_chars, int radix) {
|
||||
if (radix != 10)
|
||||
return EINVAL;
|
||||
|
||||
// No more than 12 characters will be required for a 32-bit integer.
|
||||
// Add an extra byte for the terminating null.
|
||||
char temp[13];
|
||||
int written = snprintf(temp, sizeof(temp), "%d", value);
|
||||
if (static_cast<size_t>(written) >= size_in_chars) {
|
||||
// Output was truncated, or written was negative.
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
for (int i = 0; i < written; ++i) {
|
||||
buffer[i] = static_cast<char16_t>(temp[i]);
|
||||
}
|
||||
buffer[written] = '\0';
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif // !WIN32
|
||||
|
||||
} // namespace url
|
||||
|
@ -587,8 +587,6 @@ constexpr uint64_t StringToUint64WithBase(std::string_view str, uint8_t base) {
|
||||
// Implementations of Windows' int-to-string conversions
|
||||
COMPONENT_EXPORT(URL)
|
||||
int _itoa_s(int value, char* buffer, size_t size_in_chars, int radix);
|
||||
COMPONENT_EXPORT(URL)
|
||||
int _itow_s(int value, char16_t* buffer, size_t size_in_chars, int radix);
|
||||
|
||||
// Secure template overloads for these functions
|
||||
template <size_t N>
|
||||
@ -596,11 +594,6 @@ inline int _itoa_s(int value, char (&buffer)[N], int radix) {
|
||||
return _itoa_s(value, buffer, N, radix);
|
||||
}
|
||||
|
||||
template <size_t N>
|
||||
inline int _itow_s(int value, char16_t (&buffer)[N], int radix) {
|
||||
return _itow_s(value, buffer, N, radix);
|
||||
}
|
||||
|
||||
#endif // WIN32
|
||||
|
||||
// The threshold we set to consider SIMD processing, in bytes; there is
|
||||
|
@ -2654,40 +2654,6 @@ TEST_F(URLCanonTest, _itoa_s) {
|
||||
EXPECT_EQ('\xFF', buf[5]);
|
||||
}
|
||||
|
||||
TEST_F(URLCanonTest, _itow_s) {
|
||||
// We fill the buffer with 0xff to ensure that it's getting properly
|
||||
// null-terminated. We also allocate one byte more than what we tell
|
||||
// _itoa_s about, and ensure that the extra byte is untouched.
|
||||
char16_t buf[6];
|
||||
const char fill_mem = 0xff;
|
||||
const char16_t fill_char = 0xffff;
|
||||
memset(buf, fill_mem, sizeof(buf));
|
||||
EXPECT_EQ(0, _itow_s(12, buf, sizeof(buf) / 2 - 1, 10));
|
||||
EXPECT_EQ(u"12", std::u16string(buf));
|
||||
EXPECT_EQ(fill_char, buf[3]);
|
||||
|
||||
// Test the edge cases - exactly the buffer size and one over
|
||||
EXPECT_EQ(0, _itow_s(1234, buf, sizeof(buf) / 2 - 1, 10));
|
||||
EXPECT_EQ(u"1234", std::u16string(buf));
|
||||
EXPECT_EQ(fill_char, buf[5]);
|
||||
|
||||
memset(buf, fill_mem, sizeof(buf));
|
||||
EXPECT_EQ(EINVAL, _itow_s(12345, buf, sizeof(buf) / 2 - 1, 10));
|
||||
EXPECT_EQ(fill_char, buf[5]); // should never write to this location
|
||||
|
||||
// Test the template overload (note that this will see the full buffer)
|
||||
memset(buf, fill_mem, sizeof(buf));
|
||||
EXPECT_EQ(0, _itow_s(12, buf, 10));
|
||||
EXPECT_EQ(u"12", std::u16string(buf));
|
||||
EXPECT_EQ(fill_char, buf[3]);
|
||||
|
||||
memset(buf, fill_mem, sizeof(buf));
|
||||
EXPECT_EQ(0, _itow_s(12345, buf, 10));
|
||||
EXPECT_EQ(u"12345", std::u16string(buf));
|
||||
|
||||
EXPECT_EQ(EINVAL, _itow_s(123456, buf, 10));
|
||||
}
|
||||
|
||||
#endif // !WIN32
|
||||
|
||||
// Returns true if the given two structures are the same.
|
||||
|
Reference in New Issue
Block a user