Skip to content

Commit d4892ff

Browse files
more fixes
1 parent ae59310 commit d4892ff

File tree

5 files changed

+10
-10
lines changed

5 files changed

+10
-10
lines changed

libc/src/stdio/printf_core/parser.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ template <typename ArgProvider> class Parser {
265265
case ('m'):
266266
// %m is an odd conversion in that it doesn't consume an argument, it
267267
// just takes the current value of errno as its argument.
268-
section.conv_val_raw = static_cast<int>(libc_errno);
268+
section.conv_val_raw = static_cast<fputil::FPBits<double>::StorageType>(libc_errno);
269269
break;
270270
#endif // LIBC_COPT_PRINTF_DISABLE_STRERROR
271271
#ifndef LIBC_COPT_PRINTF_DISABLE_WRITE_INT

libc/src/stdio/scanf_core/parser.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ template <typename ArgProvider> class Parser {
7878
if (internal::isdigit(str[cur_pos])) {
7979
auto result = internal::strtointeger<int>(str + cur_pos, 10);
8080
section.max_width = result.value;
81-
cur_pos = cur_pos + result.parsed_len;
81+
cur_pos = cur_pos + static_cast<size_t>(result.parsed_len);
8282
}
8383

8484
// TODO(michaelrj): add posix allocate flag support.
@@ -150,7 +150,7 @@ template <typename ArgProvider> class Parser {
150150
char b = str[cur_pos + 1];
151151
char start = (a < b ? a : b);
152152
char end = (a < b ? b : a);
153-
scan_set.set_range(start, end);
153+
scan_set.set_range(static_cast<size_t>(start), static_cast<size_t>(end));
154154
cur_pos += 2;
155155
} else {
156156
scan_set.set(str[cur_pos]);

libc/src/stdlib/quick_sort.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ LIBC_INLINE void quick_sort_impl(A &array, const void *ancestor_pivot,
167167
}
168168
}
169169

170-
constexpr size_t ilog2(size_t n) { return cpp::bit_width(n) - 1; }
170+
constexpr size_t ilog2(size_t n) { return static_cast<size_t>(cpp::bit_width(n)) - 1; }
171171

172172
template <typename A, typename F>
173173
LIBC_INLINE void quick_sort(A &array, const F &is_less) {

libc/test/src/stdio/printf_core/parser_test.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ TEST(LlvmLibcPrintfParserTest, EvalOneArg) {
9797
expected.has_conv = true;
9898

9999
expected.raw_string = {str, 2};
100-
expected.conv_val_raw = arg1;
100+
expected.conv_val_raw = static_cast<LIBC_NAMESPACE::fputil::FPBits<double>::StorageType>(arg1);
101101
expected.conv_name = 'd';
102102

103103
ASSERT_PFORMAT_EQ(expected, format_arr[0]);
@@ -132,7 +132,7 @@ TEST(LlvmLibcPrintfParserTest, EvalOneArgWithFlags) {
132132
LIBC_NAMESPACE::printf_core::FormatFlags::LEADING_ZEROES |
133133
LIBC_NAMESPACE::printf_core::FormatFlags::SPACE_PREFIX |
134134
LIBC_NAMESPACE::printf_core::FormatFlags::ALTERNATE_FORM);
135-
expected.conv_val_raw = arg1;
135+
expected.conv_val_raw = static_cast<LIBC_NAMESPACE::fputil::FPBits<double>::StorageType>(arg1);
136136
expected.conv_name = 'd';
137137

138138
ASSERT_PFORMAT_EQ(expected, format_arr[0]);
@@ -149,7 +149,7 @@ TEST(LlvmLibcPrintfParserTest, EvalOneArgWithWidth) {
149149

150150
expected.raw_string = {str, 4};
151151
expected.min_width = 12;
152-
expected.conv_val_raw = arg1;
152+
expected.conv_val_raw = static_cast<LIBC_NAMESPACE::fputil::FPBits<double>::StorageType>(arg1);
153153
expected.conv_name = 'd';
154154

155155
ASSERT_PFORMAT_EQ(expected, format_arr[0]);

libc/test/src/string/memory_utils/memory_check_utils.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ inline uint16_t Checksum(cpp::span<char> dst) {
157157
uint16_t sum1 = 0;
158158
uint16_t sum2 = 0;
159159
for (char c : dst) {
160-
sum1 = (sum1 + c) % 255U;
160+
sum1 = (sum1 + static_cast<uint16_t>(c)) % 255U;
161161
sum2 = (sum2 + sum1) % 255U;
162162
}
163163
return static_cast<uint16_t>((sum2 << 8) | sum1);
@@ -185,8 +185,8 @@ template <auto FnImpl>
185185
inline bool CheckMemmove(cpp::span<char> buffer, size_t size, int overlap) {
186186
LIBC_ASSERT(buffer.size() > (2 * size + 1));
187187
const size_t half_size = buffer.size() / 2;
188-
LIBC_ASSERT((size_t)(overlap >= 0 ? overlap : -overlap) < half_size);
189-
cpp::span<char> head = buffer.first(half_size + overlap).last(size);
188+
LIBC_ASSERT(static_cast<size_t>(overlap >= 0 ? overlap : -overlap) < half_size);
189+
cpp::span<char> head = buffer.first(half_size + static_cast<size_t>(overlap)).last(size);
190190
cpp::span<char> tail = buffer.last(half_size).first(size);
191191
LIBC_ASSERT(head.size() == size);
192192
LIBC_ASSERT(tail.size() == size);

0 commit comments

Comments
 (0)