Skip to content

Commit

Permalink
Fix warnings by old gcc
Browse files Browse the repository at this point in the history
* Use PRIxSIZE instead of "z"
* Fix sign-compare warning
* Suppress unused-but-set-variable warning
  • Loading branch information
nobu committed Jun 23, 2022
1 parent 41cdf9b commit b180ffa
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
10 changes: 5 additions & 5 deletions addr2line.c
Original file line number Diff line number Diff line change
Expand Up @@ -1292,7 +1292,7 @@ hexdump0(const unsigned char *p, size_t n)
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]);
Expand All @@ -1313,16 +1313,16 @@ div_inspect(DebugInfoValue *v)
{
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;
}
Expand Down
4 changes: 2 additions & 2 deletions io_buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -680,10 +680,10 @@ io_buffer_hexdump(VALUE string, size_t width, char *base, size_t size, int first
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) {
Expand Down
3 changes: 2 additions & 1 deletion thread_win32.c
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ w32_wait_events(HANDLE *events, int count, DWORD timeout, rb_thread_t *th)
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))) {
Expand Down Expand Up @@ -347,6 +347,7 @@ native_sleep(rb_thread_t *th, rb_hrtime_t *rel)
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);
Expand Down

0 comments on commit b180ffa

Please sign in to comment.