[libc-commits] [libc] [libc] Fix implicit cast warning in strftime (PR #127282)
via libc-commits
libc-commits at lists.llvm.org
Fri Feb 14 16:05:16 PST 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-libc
Author: Michael Jones (michaelrj-google)
<details>
<summary>Changes</summary>
Forgot to change a size_t to an int, which caused warnings on gcc but
not clang for some reason. Regardless, this patch fixes the issue.
---
Full diff: https://github.com/llvm/llvm-project/pull/127282.diff
1 Files Affected:
- (modified) libc/src/time/strftime_core/composite_converter.h (+2-2)
``````````diff
diff --git a/libc/src/time/strftime_core/composite_converter.h b/libc/src/time/strftime_core/composite_converter.h
index 5c473f172c073..3530075cfe9a9 100644
--- a/libc/src/time/strftime_core/composite_converter.h
+++ b/libc/src/time/strftime_core/composite_converter.h
@@ -171,11 +171,11 @@ LIBC_INLINE int convert_full_date_time(printf_core::Writer *writer,
// we only pad the first conversion, and we assume all the other values are in
// their valid ranges.
// sizeof("Sun Jan 12 03:45:06 2025")
- const size_t full_conv_len = 3 + 1 + 3 + 1 + 2 + 1 + 8 + 1 + 4;
+ constexpr int FULL_CONV_LEN = 3 + 1 + 3 + 1 + 2 + 1 + 8 + 1 + 4;
// use the full conv len because this isn't being passed to a proper converter
// that will handle the width of the leading conversion. Instead it has to be
// handled below.
- const int requested_padding = to_conv.min_width - full_conv_len;
+ const int requested_padding = to_conv.min_width - FULL_CONV_LEN;
cpp::string_view wday_str = unwrap_opt(time_reader.get_weekday_short_name());
cpp::string_view month_str = unwrap_opt(time_reader.get_month_short_name());
``````````
</details>
https://github.com/llvm/llvm-project/pull/127282
More information about the libc-commits
mailing list