Skip to content

Commit 1b38119

Browse files
more
1 parent 55f7de8 commit 1b38119

File tree

7 files changed

+13
-12
lines changed

7 files changed

+13
-12
lines changed

libc/src/__support/OSUtil/darwin/io.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ namespace LIBC_NAMESPACE_DECL {
1717

1818
LIBC_INLINE void write_to_stderr(cpp::string_view msg) {
1919
LIBC_NAMESPACE::syscall_impl(4 /*SYS_write*/, 2 /* stderr */,
20-
reinterpret_cast<long>(msg.data()), msg.size());
20+
reinterpret_cast<long>(msg.data()), static_cast<long>(msg.size()));
2121
}
2222

2323
} // namespace LIBC_NAMESPACE_DECL

libc/src/__support/high_precision_decimal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ class HighPrecisionDecimal {
424424
result *= 10;
425425
++cur_digit;
426426
}
427-
return result + static_cast<unsigned int>(
427+
return result + static_cast<T>(
428428
this->should_round_up(this->decimal_point, round));
429429
}
430430

libc/src/__support/str_to_float.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#include "src/__support/uint128.h"
3434
#include "src/errno/libc_errno.h" // For ERANGE
3535

36+
#include <_types/_uint32_t.h>
3637
#include <stdint.h>
3738

3839
namespace LIBC_NAMESPACE_DECL {
@@ -802,7 +803,7 @@ LIBC_INLINE FloatConvertReturn<T> binary_exp_to_float(ExpandedFloat<T> init_num,
802803

803804
// Handle subnormals.
804805
if (biased_exponent <= 0) {
805-
amount_to_shift_right += 1 - biased_exponent;
806+
amount_to_shift_right += static_cast<uint32_t>(1 - biased_exponent);
806807
biased_exponent = 0;
807808

808809
if (amount_to_shift_right > FPBits::STORAGE_LEN) {
@@ -909,7 +910,7 @@ decimal_string_to_float(const char *__restrict src, const char DECIMAL_POINT,
909910
cpp::numeric_limits<StorageType>::max() / BASE;
910911
while (true) {
911912
if (isdigit(src[index])) {
912-
uint32_t digit = b36_char_to_int(src[index]);
913+
uint32_t digit = static_cast<uint32_t>(b36_char_to_int(src[index]));
913914
seen_digit = true;
914915

915916
if (mantissa < bitstype_max_div_by_base) {
@@ -956,7 +957,7 @@ decimal_string_to_float(const char *__restrict src, const char DECIMAL_POINT,
956957
if (result.has_error())
957958
output.error = result.error;
958959
int32_t add_to_exponent = result.value;
959-
index += result.parsed_len;
960+
index += static_cast<size_t>(result.parsed_len);
960961

961962
// Here we do this operation as int64 to avoid overflow.
962963
int64_t temp_exponent = static_cast<int64_t>(exponent) +
@@ -1020,7 +1021,7 @@ hexadecimal_string_to_float(const char *__restrict src,
10201021
cpp::numeric_limits<StorageType>::max() / BASE;
10211022
while (true) {
10221023
if (isalnum(src[index])) {
1023-
uint32_t digit = b36_char_to_int(src[index]);
1024+
uint32_t digit = static_cast<uint32_t>(b36_char_to_int(src[index]));
10241025
if (digit < BASE)
10251026
seen_digit = true;
10261027
else
@@ -1070,7 +1071,7 @@ hexadecimal_string_to_float(const char *__restrict src,
10701071
output.error = result.error;
10711072

10721073
int32_t add_to_exponent = result.value;
1073-
index += result.parsed_len;
1074+
index += static_cast<size_t>(result.parsed_len);
10741075

10751076
// Here we do this operation as int64 to avoid overflow.
10761077
int64_t temp_exponent = static_cast<int64_t>(exponent) +

libc/src/stdio/printf_core/writer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ class Writer final {
135135
chars_written += static_cast<int>(length);
136136

137137
if (LIBC_LIKELY(wb->buff_cur + length <= wb->buff_len)) {
138-
inline_memset(wb->buff + wb->buff_cur, new_char, length);
138+
inline_memset(wb->buff + wb->buff_cur, static_cast<unsigned char>(new_char), length);
139139
wb->buff_cur += length;
140140
return WRITE_OK;
141141
}

libc/test/src/__support/arg_list_test.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ long int check_primitives(int first, ...) {
7272
count += args.next_var<unsigned long>();
7373
count += args.next_var<long long>();
7474
count += args.next_var<unsigned long long>();
75-
count += args.next_var<double>();
76-
count += args.next_var<double>();
75+
count += static_cast<long int>(args.next_var<double>());
76+
count += static_cast<long int>(args.next_var<double>());
7777
count += args.next_var<long double>();
7878
count += *args.next_var<int *>();
7979
return count;

libc/test/src/__support/blockstore_test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class LlvmLibcBlockStoreTest : public LIBC_NAMESPACE::testing::Test {
2727
for (auto iter = block_store.begin(); iter != end; ++iter, ++i) {
2828
Element &e = *iter;
2929
if (REVERSE) {
30-
int j = ELEMENT_COUNT - 1 - i;
30+
int j = static_cast<int>(ELEMENT_COUNT - 1) - i;
3131
ASSERT_EQ(e.a, j);
3232
ASSERT_EQ(e.b, long(j * 2));
3333
ASSERT_EQ(e.c, unsigned(j * 3));

libc/test/src/__support/integer_to_string_test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ TEST(LlvmLibcIntegerToStringTest, UINT8) {
4141
EXPECT(type, 12, "12");
4242
EXPECT(type, 123, "123");
4343
EXPECT(type, UINT8_MAX, "255");
44-
EXPECT(type, -1, "255");
44+
EXPECT(type, static_cast<unsigned char>(-1), "255");
4545
}
4646

4747
TEST(LlvmLibcIntegerToStringTest, INT8) {

0 commit comments

Comments
 (0)