diff options
| author | Augie Fackler <augie@google.com> | 2025-03-05 13:52:31 -0500 |
|---|---|---|
| committer | Augie Fackler <augie@google.com> | 2025-03-05 16:42:40 -0500 |
| commit | da61b0ddc5dcc8f1ac64eaddabdbfec5aa23f22b (patch) | |
| tree | 8750d4c36c31e7d3babb229377b1c521dc9d21d7 /libc/src/stdio | |
| parent | 46236f4c3dbe11e14fe7ac1f4b903637efedfecf (diff) | |
Revert "[libc] Enable -Wconversion for tests. (#127523)"
This reverts commit 1e6e845d49a336e9da7ca6c576ec45c0b419b5f6 because it
changed the 1st parameter of adjust() to be unsigned, but libc itself
calls adjust() with a negative argument in align_backward() in
op_generic.h.
Diffstat (limited to 'libc/src/stdio')
| -rw-r--r-- | libc/src/stdio/printf_core/parser.h | 18 | ||||
| -rw-r--r-- | libc/src/stdio/printf_core/writer.h | 3 | ||||
| -rw-r--r-- | libc/src/stdio/scanf_core/parser.h | 13 |
3 files changed, 15 insertions, 19 deletions
diff --git a/libc/src/stdio/printf_core/parser.h b/libc/src/stdio/printf_core/parser.h index 89556f1a9e5f..acbbaa25b1c9 100644 --- a/libc/src/stdio/printf_core/parser.h +++ b/libc/src/stdio/printf_core/parser.h @@ -57,8 +57,7 @@ template <typename T> using int_type_of_v = typename int_type_of<T>::type; if (!temp.has_value()) { \ section.has_conv = false; \ } else { \ - dst = static_cast<decltype(dst)>( \ - cpp::bit_cast<int_type_of_v<arg_type>>(temp.value())); \ + dst = cpp::bit_cast<int_type_of_v<arg_type>>(temp.value()); \ } \ } #else @@ -131,7 +130,7 @@ public: } else if (internal::isdigit(str[cur_pos])) { auto result = internal::strtointeger<int>(str + cur_pos, 10); section.min_width = result.value; - cur_pos = cur_pos + static_cast<size_t>(result.parsed_len); + cur_pos = cur_pos + result.parsed_len; } if (section.min_width < 0) { section.min_width = @@ -154,7 +153,7 @@ public: } else if (internal::isdigit(str[cur_pos])) { auto result = internal::strtointeger<int>(str + cur_pos, 10); section.precision = result.value; - cur_pos = cur_pos + static_cast<size_t>(result.parsed_len); + cur_pos = cur_pos + result.parsed_len; } } @@ -266,8 +265,7 @@ public: case ('m'): // %m is an odd conversion in that it doesn't consume an argument, it // just takes the current value of errno as its argument. - section.conv_val_raw = - static_cast<fputil::FPBits<double>::StorageType>(libc_errno); + section.conv_val_raw = static_cast<int>(libc_errno); break; #endif // LIBC_COPT_PRINTF_DISABLE_STRERROR #ifndef LIBC_COPT_PRINTF_DISABLE_WRITE_INT @@ -358,7 +356,7 @@ private: } if (internal::isdigit(str[*local_pos])) { const auto result = internal::strtointeger<int>(str + *local_pos, 10); - *local_pos += static_cast<size_t>(result.parsed_len); + *local_pos += result.parsed_len; return {lm, static_cast<size_t>(cpp::max(0, result.value))}; } return {lm, 0}; @@ -407,10 +405,10 @@ private: LIBC_INLINE size_t parse_index(size_t *local_pos) { if (internal::isdigit(str[*local_pos])) { auto result = internal::strtointeger<int>(str + *local_pos, 10); - size_t index = static_cast<size_t>(result.value); - if (str[*local_pos + static_cast<size_t>(result.parsed_len)] != '$') + size_t index = result.value; + if (str[*local_pos + result.parsed_len] != '$') return 0; - *local_pos = static_cast<size_t>(1 + result.parsed_len) + *local_pos; + *local_pos = 1 + result.parsed_len + *local_pos; return index; } return 0; diff --git a/libc/src/stdio/printf_core/writer.h b/libc/src/stdio/printf_core/writer.h index 28c9a2827087..5526a478ea62 100644 --- a/libc/src/stdio/printf_core/writer.h +++ b/libc/src/stdio/printf_core/writer.h @@ -135,8 +135,7 @@ public: chars_written += static_cast<int>(length); if (LIBC_LIKELY(wb->buff_cur + length <= wb->buff_len)) { - inline_memset(wb->buff + wb->buff_cur, - static_cast<unsigned char>(new_char), length); + inline_memset(wb->buff + wb->buff_cur, new_char, length); wb->buff_cur += length; return WRITE_OK; } diff --git a/libc/src/stdio/scanf_core/parser.h b/libc/src/stdio/scanf_core/parser.h index 1e2f26e0d3fd..6cc5b30eb0db 100644 --- a/libc/src/stdio/scanf_core/parser.h +++ b/libc/src/stdio/scanf_core/parser.h @@ -78,7 +78,7 @@ public: if (internal::isdigit(str[cur_pos])) { auto result = internal::strtointeger<int>(str + cur_pos, 10); section.max_width = result.value; - cur_pos = cur_pos + static_cast<size_t>(result.parsed_len); + cur_pos = cur_pos + result.parsed_len; } // TODO(michaelrj): add posix allocate flag support. @@ -150,11 +150,10 @@ public: char b = str[cur_pos + 1]; char start = (a < b ? a : b); char end = (a < b ? b : a); - scan_set.set_range(static_cast<size_t>(start), - static_cast<size_t>(end)); + scan_set.set_range(start, end); cur_pos += 2; } else { - scan_set.set(static_cast<size_t>(str[cur_pos])); + scan_set.set(str[cur_pos]); ++cur_pos; } } @@ -238,10 +237,10 @@ private: LIBC_INLINE size_t parse_index(size_t *local_pos) { if (internal::isdigit(str[*local_pos])) { auto result = internal::strtointeger<int>(str + *local_pos, 10); - size_t index = static_cast<size_t>(result.value); - if (str[*local_pos + static_cast<size_t>(result.parsed_len)] != '$') + size_t index = result.value; + if (str[*local_pos + result.parsed_len] != '$') return 0; - *local_pos = static_cast<size_t>(1 + result.parsed_len) + *local_pos; + *local_pos = 1 + result.parsed_len + *local_pos; return index; } return 0; |
