Skip to content

Commit 28a9403

Browse files
committed
fix GCC warnings for the target with long uint32_t
Note: on some targets, int32_t is a long. eg. GCC in the recent ESP-IDF has such a configuration. references: apache/nuttx#16022 https://docs.espressif.com/projects/esp-idf/en/stable/esp32/migration-guides/release-5.x/5.0/gcc.html#espressif-toolchain-changes
1 parent 04861b1 commit 28a9403

File tree

16 files changed

+30
-20
lines changed

16 files changed

+30
-20
lines changed

lib/exec.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,8 +253,8 @@ frame_enter(struct exec_context *ctx, struct instance *inst, uint32_t funcidx,
253253
#endif
254254
cells_zero(locals + nparams, nlocals - nparams);
255255

256-
xlog_trace_insn("frame enter: maxlabels %u maxcells %u", ei->maxlabels,
257-
ei->maxcells);
256+
xlog_trace_insn("frame enter: maxlabels %" PRIu32 " maxcells %" PRIu32,
257+
ei->maxlabels, ei->maxcells);
258258
uint32_t i;
259259
for (i = 0; i < nlocals; i++) {
260260
if (i == nparams) {

lib/exec_debug.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
#define VEC_PRINT_USAGE(name, vec) \
1313
nbio_printf("%s %" PRIu32 " (%zu bytes)\n", (name), (vec)->psize, \
14-
(vec)->psize * sizeof(*(vec)->p));
14+
(size_t)(vec)->psize * sizeof(*(vec)->p));
1515

1616
#define STAT_PRINT(name) \
1717
nbio_printf("%23s %12" PRIu64 "\n", #name, ctx->stats.name);

lib/exec_insn_subr.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ memory_getptr2(struct exec_context *ctx, uint32_t memidx, uint32_t ptr,
131131
" + %08" PRIx32 ", size %" PRIu32
132132
", meminst size %" PRIu32 ", pagesize %" PRIu32,
133133
memidx, ptr, offset, size, meminst->size_in_pages,
134-
1 << memtype_page_shift(meminst->type));
134+
memtype_page_size(meminst->type));
135135
assert(ret != 0);
136136
}
137137
return ret;
@@ -706,7 +706,7 @@ retry:;
706706
}
707707
memory_atomic_unlock(lock);
708708
if (ret == 0) {
709-
xlog_trace("%s: returning %d result %d", __func__, ret,
709+
xlog_trace("%s: returning %d result %" PRIu32, __func__, ret,
710710
*resultp);
711711
} else {
712712
xlog_trace("%s: returning %d", __func__, ret);

lib/expr.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ read_expr_common(const uint8_t **pp, const uint8_t *ep, struct expr *expr,
245245
#endif
246246
xlog_trace("code size %zu, jump table size %zu, max labels %" PRIu32
247247
", cells %" PRIu32,
248-
p - expr->start, ei->njumps * sizeof(*ei->jumps),
248+
p - expr->start, (size_t)ei->njumps * sizeof(*ei->jumps),
249249
ei->maxlabels, ei->maxcells);
250250
validation_context_reuse(vctx);
251251
return 0;

lib/host_instance.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ host_func_getptr2(struct exec_context *ctx, struct meminst *mem, uint32_t ptr,
219219
", size %" PRIu32 ", meminst size %" PRIu32
220220
", pagesize %" PRIu32,
221221
ptr, size, mem->size_in_pages,
222-
1 << memtype_page_shift(mem->type));
222+
memtype_page_size(mem->type));
223223
}
224224
return ret;
225225
}

lib/insn_impl_control.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,8 @@ INSN_IMPL(call_indirect)
511511
goto fail;
512512
}
513513
const struct functype *ft = &m->types[typeidx];
514-
xlog_trace_insn("call_indirect (table %u type %u) %u %u",
514+
xlog_trace_insn("call_indirect (table %" PRIu32
515+
" type %" PRIu32 ") %" PRIu32 " %" PRIu32,
515516
tableidx, typeidx, ft->parameter.ntypes,
516517
ft->result.ntypes);
517518
ret = pop_valtypes(&ft->parameter, vctx);

lib/insn_impl_tailcall.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ INSN_IMPL(return_call_indirect)
7070
goto fail;
7171
}
7272
const struct functype *ft = &m->types[typeidx];
73-
xlog_trace_insn("call_indirect (table %u type %u) %u %u",
73+
xlog_trace_insn("call_indirect (table %" PRIu32
74+
" type %" PRIu32 ") %" PRIu32 " %" PRIu32,
7475
tableidx, typeidx, ft->parameter.ntypes,
7576
ft->result.ntypes);
7677
ret = pop_valtypes(&ft->parameter, vctx);

lib/instance.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -782,6 +782,6 @@ instance_print_stats(const struct instance *inst)
782782
" pages (min/max=%" PRIu32 "/%" PRIu32
783783
" pagesize=%" PRIu32 ")\n",
784784
i, mi->allocated, mi->size_in_pages, lim->min,
785-
lim->max, 1 << memtype_page_shift(mi->type));
785+
lim->max, memtype_page_size(mi->type));
786786
}
787787
}

lib/module.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1637,7 +1637,8 @@ read_code_section(const uint8_t **pp, const uint8_t *ep,
16371637

16381638
uint32_t i;
16391639
for (i = 0; i < m->nfuncs; i++) {
1640-
xlog_trace("func nlocals %u", m->funcs[i].localtype.nlocals);
1640+
xlog_trace("func nlocals %" PRIu32,
1641+
m->funcs[i].localtype.nlocals);
16411642
}
16421643

16431644
*pp = p;
@@ -2214,7 +2215,7 @@ module_load_into(struct module *m, const uint8_t *p, const uint8_t *ep,
22142215
goto fail;
22152216
}
22162217
if (v != 1) { /* version */
2217-
report_error(&ctx->report, "wrong version: %u", v);
2218+
report_error(&ctx->report, "wrong version: %" PRIu32, v);
22182219
ret = EINVAL;
22192220
goto fail;
22202221
}

lib/type.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,3 +449,9 @@ memtype_page_shift(const struct memtype *type)
449449
return WASM_PAGE_SHIFT;
450450
#endif
451451
}
452+
453+
uint32_t
454+
memtype_page_size(const struct memtype *type)
455+
{
456+
return UINT32_C(1) << memtype_page_shift(type);
457+
}

0 commit comments

Comments
 (0)