Skip to content

Commit 61b9e99

Browse files
another
1 parent 1b38119 commit 61b9e99

File tree

4 files changed

+8
-9
lines changed

4 files changed

+8
-9
lines changed

libc/src/__support/str_to_float.h

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

36-
#include <_types/_uint32_t.h>
3736
#include <stdint.h>
3837

3938
namespace LIBC_NAMESPACE_DECL {
@@ -109,11 +108,11 @@ eisel_lemire(ExpandedFloat<T> init_num,
109108
}
110109

111110
// Normalization
112-
uint32_t clz = cpp::countl_zero<StorageType>(mantissa);
111+
uint32_t clz = static_cast<uint32_t>(cpp::countl_zero<StorageType>(mantissa));
113112
mantissa <<= clz;
114113

115114
int32_t exp2 =
116-
exp10_to_exp2(exp10) + FPBits::STORAGE_LEN + FPBits::EXP_BIAS - clz;
115+
exp10_to_exp2(exp10) + FPBits::STORAGE_LEN + FPBits::EXP_BIAS - static_cast<int32_t>(clz);
117116

118117
// Multiplication
119118
const uint64_t *power_of_ten =
@@ -1136,7 +1135,7 @@ LIBC_INLINE StrToNumResult<T> strtofloatingpoint(const char *__restrict src) {
11361135

11371136
int error = 0;
11381137

1139-
ptrdiff_t index = first_non_whitespace(src) - src;
1138+
size_t index = static_cast<size_t>(first_non_whitespace(src) - src);
11401139

11411140
if (src[index] == '+' || src[index] == '-') {
11421141
sign = src[index];
@@ -1246,7 +1245,7 @@ LIBC_INLINE StrToNumResult<T> strtofloatingpoint(const char *__restrict src) {
12461245
// special 80 bit long doubles. Otherwise it should be inlined out.
12471246
set_implicit_bit<T>(result);
12481247

1249-
return {result.get_val(), index, error};
1248+
return {result.get_val(), static_cast<ptrdiff_t>(index), error};
12501249
}
12511250

12521251
template <class T> LIBC_INLINE StrToNumResult<T> strtonan(const char *arg) {

libc/test/src/__support/fixedvector_test.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ TEST(LlvmLibcFixedVectorTest, ForwardIteration) {
9292
LIBC_NAMESPACE::FixedVector<int, 5> vec(arr.begin(), arr.end());
9393
ASSERT_EQ(vec.size(), arr.size());
9494
for (auto it = vec.begin(); it != vec.end(); ++it) {
95-
auto idx = it - vec.begin();
95+
auto idx = static_cast<size_t>(it - vec.begin());
9696
ASSERT_EQ(*it, arr[idx]);
9797
}
9898
}
@@ -102,7 +102,7 @@ TEST(LlvmLibcFixedVectorTest, ConstForwardIteration) {
102102
const LIBC_NAMESPACE::FixedVector<int, 5> vec(arr.begin(), arr.end());
103103
ASSERT_EQ(vec.size(), arr.size());
104104
for (auto it = vec.begin(); it != vec.end(); ++it) {
105-
auto idx = it - vec.begin();
105+
auto idx = static_cast<size_t>(it - vec.begin());
106106
ASSERT_EQ(*it, arr[idx]);
107107
}
108108
}

libc/test/src/__support/hash_test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ TEST(LlvmLibcHashTest, Avalanche) {
7878
}
7979
for (size_t i = 0; i < sz; ++i) {
8080
for (size_t j = 0; j < 8; ++j) {
81-
uint8_t mask = 1 << j;
81+
uint8_t mask = static_cast<uint8_t>(1 << j);
8282
mem.data[i] ^= mask;
8383
{
8484
LIBC_NAMESPACE::internal::HashState state{0xabcdef1234567890};

libc/test/src/__support/str_to_double_test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ TEST(LlvmLibcStrToDblTest, SimpleDecimalConversionExtraTypes) {
104104
internal::simple_decimal_conversion<double>("123456789012345678900");
105105

106106
double_output_mantissa = double_result.num.mantissa;
107-
output_exp2 = double_result.num.exponent;
107+
output_exp2 = static_cast<uint32_t>(double_result.num.exponent);
108108

109109
EXPECT_EQ(double_output_mantissa, uint64_t(0x1AC53A7E04BCDA));
110110
EXPECT_EQ(output_exp2, uint32_t(1089));

0 commit comments

Comments
 (0)