Skip to content

Commit e766cb3

Browse files
S-H-GAMELINKSnobu
authored andcommitted
Suppress warnings in time_init_parse function
When building Ruby on Ubuntu 22.04 and GCC 11.4.0, the following warning appeared. And this change has suppressed warning. ``` compiling ../ruby/time.c ../ruby/time.c: In function ‘time_init_parse’: ../ruby/time.c:2650:21: warning: comparison of integer expressions of different signedness: ‘size_t’ {aka ‘long unsigned int’} and ‘int’ [-Wsign-compare] 2650 | if (ndigits < TIME_SCALE_NUMDIGITS) { | ^ ../ruby/time.c:2654:26: warning: comparison of integer expressions of different signedness: ‘size_t’ {aka ‘long unsigned int’} and ‘int’ [-Wsign-compare] 2654 | else if (ndigits > TIME_SCALE_NUMDIGITS) { | ```
1 parent 563263a commit e766cb3

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

time.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2647,11 +2647,11 @@ time_init_parse(rb_execution_context_t *ec, VALUE time, VALUE str, VALUE zone, V
26472647
}
26482648
if (!NIL_P(subsec)) {
26492649
/* subseconds is the last using ndigits */
2650-
if (ndigits < TIME_SCALE_NUMDIGITS) {
2650+
if (ndigits < (size_t)TIME_SCALE_NUMDIGITS) {
26512651
VALUE mul = rb_int_positive_pow(10, TIME_SCALE_NUMDIGITS - ndigits);
26522652
subsec = rb_int_mul(subsec, mul);
26532653
}
2654-
else if (ndigits > TIME_SCALE_NUMDIGITS) {
2654+
else if (ndigits > (size_t)TIME_SCALE_NUMDIGITS) {
26552655
VALUE num = rb_int_positive_pow(10, ndigits - TIME_SCALE_NUMDIGITS);
26562656
subsec = rb_rational_new(subsec, num);
26572657
}

0 commit comments

Comments
 (0)