Skip to content

Commit 32111e1

Browse files
authored
Fix mono native warnings from wasm targets (#64650)
* Fix mono native warnings from wasm targets * Add back Werror option * Use tabs for indent
1 parent 0e1cada commit 32111e1

File tree

11 files changed

+30
-30
lines changed

11 files changed

+30
-30
lines changed

src/mono/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -737,7 +737,7 @@ else()
737737
set(EGLIB_SEARCHSEP ":")
738738
set(EGLIB_OS "UNIX")
739739
set(EGLIB_PIDTYPE "int")
740-
set(EGLIB_GSIZE_FORMAT "\"lu\"")
740+
set(EGLIB_GSIZE_FORMAT "\"zu\"")
741741
endif()
742742

743743
set(EGLIB_GSIZE "size_t")

src/mono/mono/metadata/seq-points-data.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -409,9 +409,12 @@ mono_seq_point_data_read (SeqPointData *data, char *path)
409409
fseek(f, 0, SEEK_SET);
410410

411411
buffer_orig = buffer = (guint8 *)g_malloc (fsize + 1);
412-
size_t items = fread(buffer_orig, fsize, 1, f);
413-
if (items != 1)
412+
size_t len = fread(buffer_orig, fsize, 1, f);
413+
if (ferror(f)) {
414+
fclose(f);
414415
return FALSE;
416+
}
417+
g_assert (len == fsize || (len < fsize && feof(f)));
415418

416419
fclose(f);
417420

src/mono/mono/metadata/sre.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2406,7 +2406,7 @@ mono_reflection_get_custom_attrs_blob_checked (MonoReflectionAssembly *assembly,
24062406
MonoObject *prop;
24072407

24082408
for (i = 0; i < mono_array_length_internal (properties); ++i) {
2409-
MonoType *ptype;
2409+
MonoType *ptype = NULL;
24102410
char *pname;
24112411

24122412
prop = (MonoObject *)mono_array_get_internal (properties, gpointer, i);
@@ -2430,7 +2430,7 @@ mono_reflection_get_custom_attrs_blob_checked (MonoReflectionAssembly *assembly,
24302430
MonoObject *field;
24312431

24322432
for (i = 0; i < mono_array_length_internal (fields); ++i) {
2433-
MonoType *ftype;
2433+
MonoType *ftype = NULL;
24342434
char *fname;
24352435

24362436
field = (MonoObject *)mono_array_get_internal (fields, gpointer, i);

src/mono/mono/mini/aot-compiler.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8350,6 +8350,8 @@ parse_cpu_features (const gchar *attr)
83508350
#elif defined(TARGET_WASM)
83518351
if (!strcmp (attr + prefix, "simd"))
83528352
feature = MONO_CPU_WASM_SIMD;
8353+
#else
8354+
(void)prefix; // unused
83538355
#endif
83548356

83558357
if (enabled)

src/mono/mono/mini/cfgdump.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,21 +70,23 @@ create_socket (const char *hostname, const int port)
7070
static void
7171
write_byte (MonoCompile *cfg, unsigned char b)
7272
{
73-
write (cfg->gdump_ctx->fd, &b, 1);
73+
int ret;
74+
while ((ret = write (cfg->gdump_ctx->fd, &b, 1)) < 0 && errno == EINTR);
7475
}
7576

7677
static void
7778
write_short (MonoCompile *cfg, short s)
7879
{
7980
short swap = htons (s);
80-
write (cfg->gdump_ctx->fd, &swap, 2);
81+
int ret;
82+
while ((ret = write (cfg->gdump_ctx->fd, &swap, 2)) < 0 && errno == EINTR);
8183
}
8284

8385
static void
8486
write_int (MonoCompile *cfg, int v)
8587
{
86-
int swap = htonl (v);
87-
write (cfg->gdump_ctx->fd, &swap, 4);
88+
int swap = htonl (v), ret;
89+
while ((ret = write (cfg->gdump_ctx->fd, &swap, 4)) < 0 && errno == EINTR);
8890
}
8991

9092
static void

src/mono/mono/mini/mini-llvm.c

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1460,12 +1460,10 @@ sig_to_llvm_sig_no_cinfo (EmitContext *ctx, MonoMethodSignature *sig)
14601460
LLVMTypeRef *param_types = NULL;
14611461
LLVMTypeRef res;
14621462
int i, pindex;
1463-
MonoType *rtype;
14641463

14651464
ret_type = type_to_llvm_type (ctx, sig->ret);
14661465
if (!ctx_ok (ctx))
14671466
return NULL;
1468-
rtype = mini_get_underlying_type (sig->ret);
14691467

14701468
param_types = g_new0 (LLVMTypeRef, (sig->param_count * 8) + 3);
14711469
pindex = 0;
@@ -2002,10 +2000,6 @@ get_aotconst (EmitContext *ctx, MonoJumpInfoType type, gconstpointer data, LLVMT
20022000

20032001
cfg = ctx->cfg;
20042002

2005-
MonoJumpInfo tmp_ji;
2006-
tmp_ji.type = type;
2007-
tmp_ji.data.target = data;
2008-
20092003
load = get_aotconst_module (ctx->module, ctx->builder, type, data, llvm_type, &got_offset, &ji);
20102004

20112005
ji->next = cfg->patch_info;
@@ -3805,13 +3799,11 @@ emit_entry_bb (EmitContext *ctx, LLVMBuilderRef builder)
38053799
*/
38063800
for (i = 0; i < cfg->num_varinfo; ++i) {
38073801
MonoInst *var = cfg->varinfo [i];
3808-
LLVMTypeRef vtype;
38093802

38103803
if ((var->opcode == OP_GSHAREDVT_LOCAL || var->opcode == OP_GSHAREDVT_ARG_REGOFFSET))
38113804
continue;
38123805

38133806
if (var->flags & (MONO_INST_VOLATILE|MONO_INST_INDIRECT) || (mini_type_is_vtype (var->inst_vtype) && !MONO_CLASS_IS_SIMD (ctx->cfg, var->klass))) {
3814-
vtype = type_to_llvm_type (ctx, var->inst_vtype);
38153807
if (!ctx_ok (ctx))
38163808
return;
38173809
/* Could be already created by an OP_VPHI */
@@ -4016,6 +4008,7 @@ emit_entry_bb (EmitContext *ctx, LLVMBuilderRef builder)
40164008
rgctx_alloc = ctx->addresses [cfg->rgctx_var->dreg];
40174009
/* This volatile store will keep the alloca alive */
40184010
store = mono_llvm_build_store (builder, convert (ctx, ctx->rgctx_arg, IntPtrType ()), rgctx_alloc, TRUE, LLVM_BARRIER_NONE);
4011+
(void)store; /* unused */
40194012

40204013
set_metadata_flag (rgctx_alloc, "mono.this");
40214014
}
@@ -4867,15 +4860,13 @@ static const char *default_personality_name = "__gxx_personality_v0";
48674860
static LLVMTypeRef
48684861
default_cpp_lpad_exc_signature (void)
48694862
{
4870-
static gboolean inited = FALSE;
48714863
static LLVMTypeRef sig;
48724864

48734865
if (!sig) {
48744866
LLVMTypeRef signature [2];
48754867
signature [0] = LLVMPointerType (LLVMInt8Type (), 0);
48764868
signature [1] = LLVMInt32Type ();
48774869
sig = LLVMStructType (signature, 2, FALSE);
4878-
inited = TRUE;
48794870
}
48804871

48814872
return sig;
@@ -5495,7 +5486,7 @@ process_bb (EmitContext *ctx, MonoBasicBlock *bb)
54955486
BBInfo *bblocks = ctx->bblocks;
54965487
MonoInst *ins;
54975488
LLVMBasicBlockRef cbb;
5498-
LLVMBuilderRef builder, starting_builder;
5489+
LLVMBuilderRef builder;
54995490
gboolean has_terminator;
55005491
LLVMValueRef v;
55015492
LLVMValueRef lhs, rhs, arg3;
@@ -5610,7 +5601,6 @@ process_bb (EmitContext *ctx, MonoBasicBlock *bb)
56105601
}
56115602

56125603
has_terminator = FALSE;
5613-
starting_builder = builder;
56145604
for (ins = bb->code; ins; ins = ins->next) {
56155605
const char *spec = LLVM_INS_INFO (ins->opcode);
56165606
char *dname = NULL;
@@ -12219,11 +12209,9 @@ mono_llvm_emit_call (MonoCompile *cfg, MonoCallInst *call)
1221912209
{
1222012210
MonoInst *in;
1222112211
MonoMethodSignature *sig;
12222-
int i, n, stack_size;
12212+
int i, n;
1222312213
LLVMArgInfo *ainfo;
1222412214

12225-
stack_size = 0;
12226-
1222712215
sig = call->signature;
1222812216
n = sig->param_count + sig->hasthis;
1222912217

src/mono/mono/mini/mini.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1909,15 +1909,15 @@ realloc_code (MonoCompile *cfg, int size)
19091909
const int EXTRA_CODE_SPACE = 16;
19101910
const int code_len = cfg->code_len;
19111911

1912-
if (G_UNLIKELY (code_len + size > (cfg->code_size - EXTRA_CODE_SPACE)))
1912+
if (G_UNLIKELY ((guint)(code_len + size) > (cfg->code_size - EXTRA_CODE_SPACE)))
19131913
return mini_realloc_code_slow (cfg, size);
19141914
return cfg->native_code + code_len;
19151915
}
19161916

19171917
static inline void
19181918
set_code_len (MonoCompile *cfg, int len)
19191919
{
1920-
g_assert (len <= cfg->code_size);
1920+
g_assert ((guint)len <= cfg->code_size);
19211921
cfg->code_len = len;
19221922
}
19231923

src/mono/mono/mini/type-checking.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,7 @@ handle_isinst (MonoCompile *cfg, MonoClass *klass, MonoInst *src, int context_us
557557

558558
MONO_START_BB (cfg, pointer_check_bb);
559559
// Check if the parent class of the element is non-null, else manually check the type
560-
MONO_EMIT_NEW_BIALU_IMM (cfg, OP_COMPARE_IMM, -1, parent_reg, NULL);
560+
MONO_EMIT_NEW_BIALU_IMM (cfg, OP_COMPARE_IMM, -1, parent_reg, 0);
561561
MONO_EMIT_NEW_BRANCH_BLOCK (cfg, OP_PBNE_UN, is_null_bb);
562562
MONO_EMIT_NEW_BIALU_IMM (cfg, OP_COMPARE_IMM, -1, class_kind_reg, MONO_CLASS_POINTER);
563563
MONO_EMIT_NEW_BRANCH_BLOCK (cfg, OP_PBEQ, false_bb);

src/mono/mono/sgen/sgen-protocol.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,12 @@ binary_protocol_open_file (gboolean assert_on_failure)
115115
#endif
116116
} else {
117117
/* We have acquired the lock. Truncate the file */
118-
ftruncate (binary_protocol_file, 0);
118+
int ret;
119+
while ((ret = ftruncate (binary_protocol_file, 0)) < 0 && errno == EINTR);
120+
if (ret < 0) {
121+
binary_protocol_file = -1;
122+
break;
123+
}
119124
}
120125
} while (binary_protocol_file == -1);
121126
#else

src/mono/mono/tools/offsets-tool/offsets-tool.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ def run_clang(self):
281281
clang_args += self.target_args
282282
clang_args += ['-std=gnu99', '-DMONO_GENERATING_OFFSETS']
283283
for include in self.sys_includes:
284-
clang_args.append ("-I")
284+
clang_args.append ("-isystem")
285285
clang_args.append (include)
286286
for include in mono_includes:
287287
clang_args.append ("-I")

0 commit comments

Comments
 (0)