From 798a115a15f872654916e0a3d3ae58efe4f64e42 Mon Sep 17 00:00:00 2001 From: Takashi Kokubun Date: Mon, 23 Sep 2024 16:39:24 -0700 Subject: [PATCH] Fix a -Wsign-compare warning MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ../time.c:5247:50: warning: operand of ‘?:’ changes signedness from ‘int’ to ‘long unsigned int’ due to unsignedness of other operand [-Wsign-compare] 5247 | int w = (year >= -9999 && year <= 9999 ? year_width : (int)(year < 0) + DECIMAL_SIZE_OF(year)); | ^~~~~~~~~~ --- time.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/time.c b/time.c index 1f8cb3bf0b..e3f58e3645 100644 --- a/time.c +++ b/time.c @@ -5244,7 +5244,7 @@ time_xmlschema(int argc, VALUE *argv, VALUE time) if (FIXNUM_P(tobj->vtm.year)) { long year = FIX2LONG(tobj->vtm.year); int year_width = (year < 0) + rb_strlen_lit("YYYY"); - int w = (year >= -9999 && year <= 9999 ? year_width : (year < 0) + DECIMAL_SIZE_OF(year)); + int w = (year >= -9999 && year <= 9999 ? year_width : (year < 0) + (int)DECIMAL_SIZE_OF(year)); str = rb_usascii_str_new(0, w + size_after_year); ptr = RSTRING_PTR(str); fill_digits_long(w + 1, year_width, year) {