[前][次][番号順一覧][スレッド一覧]

ruby-changes:72295

From: Nobuyoshi <ko1@a...>
Date: Thu, 23 Jun 2022 22:53:49 +0900 (JST)
Subject: [ruby-changes:72295] b180ffa622 (master): Fix warnings by old gcc

https://git.ruby-lang.org/ruby.git/commit/?id=b180ffa622

From b180ffa62270dc32bb69167822b4c698def5c8f7 Mon Sep 17 00:00:00 2001
From: Nobuyoshi Nakada <nobu@r...>
Date: Thu, 23 Jun 2022 22:51:31 +0900
Subject: Fix warnings by old gcc

* Use PRIxSIZE instead of "z"
* Fix sign-compare warning
* Suppress unused-but-set-variable warning
---
 addr2line.c    | 10 +++++-----
 io_buffer.c    |  4 ++--
 thread_win32.c |  3 ++-
 3 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/addr2line.c b/addr2line.c
index aa0226e341..fe4ad84423 100644
--- a/addr2line.c
+++ b/addr2line.c
@@ -1292,7 +1292,7 @@ hexdump0(const unsigned char *p, size_t n) https://github.com/ruby/ruby/blob/trunk/addr2line.c#L1292
     for (i=0; i < n; i++){
         switch (i & 15) {
           case 0:
-            fprintf(stderr, "%02zd: %02X ", i/16, p[i]);
+            fprintf(stderr, "%02" PRIdSIZE ": %02X ", i/16, p[i]);
             break;
           case 15:
             fprintf(stderr, "%02X\n", p[i]);
@@ -1313,16 +1313,16 @@ div_inspect(DebugInfoValue *v) https://github.com/ruby/ruby/blob/trunk/addr2line.c#L1313
 {
     switch (v->type) {
       case VAL_uint:
-        fprintf(stderr,"%d: type:%d size:%zx v:%"PRIx64"\n",__LINE__,v->type,v->size,v->as.uint64);
+        fprintf(stderr,"%d: type:%d size:%" PRIxSIZE " v:%"PRIx64"\n",__LINE__,v->type,v->size,v->as.uint64);
         break;
       case VAL_int:
-        fprintf(stderr,"%d: type:%d size:%zx v:%"PRId64"\n",__LINE__,v->type,v->size,(int64_t)v->as.uint64);
+        fprintf(stderr,"%d: type:%d size:%" PRIxSIZE " v:%"PRId64"\n",__LINE__,v->type,v->size,(int64_t)v->as.uint64);
         break;
       case VAL_cstr:
-        fprintf(stderr,"%d: type:%d size:%zx v:'%s'\n",__LINE__,v->type,v->size,v->as.ptr);
+        fprintf(stderr,"%d: type:%d size:%" PRIxSIZE " v:'%s'\n",__LINE__,v->type,v->size,v->as.ptr);
         break;
       case VAL_data:
-        fprintf(stderr,"%d: type:%d size:%zx v:\n",__LINE__,v->type,v->size);
+        fprintf(stderr,"%d: type:%d size:%" PRIxSIZE " v:\n",__LINE__,v->type,v->size);
         hexdump(v->as.ptr, 16);
         break;
     }
diff --git a/io_buffer.c b/io_buffer.c
index d9a9f40bd7..7039ef71b8 100644
--- a/io_buffer.c
+++ b/io_buffer.c
@@ -680,10 +680,10 @@ io_buffer_hexdump(VALUE string, size_t width, char *base, size_t size, int first https://github.com/ruby/ruby/blob/trunk/io_buffer.c#L680
     for (size_t offset = 0; offset < size; offset += width) {
         memset(text, '\0', width);
         if (first) {
-            rb_str_catf(string, "0x%08zx ", offset);
+            rb_str_catf(string, "0x%08" PRIxSIZE " ", offset);
             first = 0;
         } else {
-            rb_str_catf(string, "\n0x%08zx ", offset);
+            rb_str_catf(string, "\n0x%08" PRIxSIZE " ", offset);
         }
 
         for (size_t i = 0; i < width; i += 1) {
diff --git a/thread_win32.c b/thread_win32.c
index ccff8bc93f..714d601340 100644
--- a/thread_win32.c
+++ b/thread_win32.c
@@ -213,7 +213,7 @@ w32_wait_events(HANDLE *events, int count, DWORD timeout, rb_thread_t *th) https://github.com/ruby/ruby/blob/trunk/thread_win32.c#L213
     DWORD ret;
 
     w32_event_debug("events:%p, count:%d, timeout:%ld, th:%u\n",
-                    events, count, timeout, th ? rb_th_serial(th) : -1);
+                    events, count, timeout, th ? rb_th_serial(th) : UINT_MAX);
 
     if (th && (intr = th->nt->interrupt_event)) {
 	if (ResetEvent(intr) && (!RUBY_VM_INTERRUPTED(th->ec) || SetEvent(intr))) {
@@ -347,6 +347,7 @@ native_sleep(rb_thread_t *th, rb_hrtime_t *rel) https://github.com/ruby/ruby/blob/trunk/thread_win32.c#L347
 	    RUBY_DEBUG_LOG("start msec:%lu", msec);
 	    ret = w32_wait_events(0, 0, msec, th);
 	    RUBY_DEBUG_LOG("done ret:%lu", ret);
+	    (void)ret;
 	}
 
         rb_native_mutex_lock(&th->interrupt_lock);
-- 
cgit v1.2.1


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]