[libc-commits] [libc] [libc] Fix implicit cast warning in strftime (PR #127282)
Michael Jones via libc-commits
libc-commits at lists.llvm.org
Fri Feb 14 16:04:43 PST 2025
https://github.com/michaelrj-google created https://github.com/llvm/llvm-project/pull/127282
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.
>From 7c7629139106459d04fd018a6dba55e014b48f50 Mon Sep 17 00:00:00 2001
From: Michael Jones <michaelrj at google.com>
Date: Fri, 14 Feb 2025 16:03:40 -0800
Subject: [PATCH] [libc] Fix implicit cast warning in strftime
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.
---
libc/src/time/strftime_core/composite_converter.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
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());
More information about the libc-commits
mailing list