Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Fix C4018 warnings round II
  • Loading branch information
fanyang-mono committed Jun 15, 2022
commit 940266acc4f46e936ea95a6c96dadeb341f62d79
18 changes: 8 additions & 10 deletions src/mono/mono/component/hot_reload.c
Original file line number Diff line number Diff line change
Expand Up @@ -933,17 +933,15 @@ scope_to_string (uint32_t tok)
static void
dump_update_summary (MonoImage *image_base, MonoImage *image_dmeta)
{
int rows;

mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_METADATA_UPDATE, "dmeta tables:");
for (int idx = 0; idx < MONO_TABLE_NUM; ++idx) {
if (image_dmeta->tables [idx].base)
mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_METADATA_UPDATE, "\t0x%02x \"%s\"", idx, mono_meta_table_name (idx));
}
mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_METADATA_UPDATE, "================================");

rows = mono_image_get_table_rows (image_base, MONO_TABLE_TYPEREF);
for (int i = 1; i <= rows; ++i) {
guint32 rows = mono_image_get_table_rows (image_base, MONO_TABLE_TYPEREF);
for (guint32 i = 1; i <= rows; ++i) {
guint32 cols [MONO_TYPEREF_SIZE];
mono_metadata_decode_row (&image_base->tables [MONO_TABLE_TYPEREF], i - 1, cols, MONO_TYPEREF_SIZE);
const char *scope = scope_to_string (cols [MONO_TYPEREF_SCOPE]);
Expand All @@ -961,7 +959,7 @@ dump_update_summary (MonoImage *image_base, MonoImage *image_dmeta)
mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_METADATA_UPDATE, "--------------------------------");

rows = mono_image_get_table_rows (image_dmeta, MONO_TABLE_TYPEREF);
for (int i = 1; i <= rows; ++i) {
for (guint32 i = 1; i <= rows; ++i) {
guint32 cols [MONO_TYPEREF_SIZE];
mono_metadata_decode_row (&image_dmeta->tables [MONO_TABLE_TYPEREF], i - 1, cols, MONO_TYPEREF_SIZE);
const char *scope = scope_to_string (cols [MONO_TYPEREF_SCOPE]);
Expand All @@ -973,7 +971,7 @@ dump_update_summary (MonoImage *image_base, MonoImage *image_dmeta)
mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_METADATA_UPDATE, "================================");

rows = mono_image_get_table_rows (image_dmeta, MONO_TABLE_TYPEDEF);
for (int i = 1; i <= rows; ++i) {
for (guint32 i = 1; i <= rows; ++i) {
guint32 cols [MONO_TYPEDEF_SIZE];
mono_metadata_decode_row (&image_dmeta->tables [MONO_TABLE_TYPEDEF], i - 1, cols, MONO_TYPEDEF_SIZE);
const char *name = mono_metadata_string_heap (image_base, cols [MONO_TYPEDEF_NAME]);
Expand All @@ -984,7 +982,7 @@ dump_update_summary (MonoImage *image_base, MonoImage *image_dmeta)
mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_METADATA_UPDATE, "================================");

rows = mono_image_get_table_rows (image_base, MONO_TABLE_METHOD);
for (int i = 1; i <= rows ; ++i) {
for (guint32 i = 1; i <= rows ; ++i) {
guint32 cols [MONO_METHOD_SIZE];
mono_metadata_decode_row_raw (&image_base->tables [MONO_TABLE_METHOD], i - 1, cols, MONO_METHOD_SIZE);
const char *name = mono_metadata_string_heap (image_base, cols [MONO_METHOD_NAME]);
Expand All @@ -994,7 +992,7 @@ dump_update_summary (MonoImage *image_base, MonoImage *image_dmeta)
mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_METADATA_UPDATE, "--------------------------------");

rows = mono_image_get_table_rows (image_dmeta, MONO_TABLE_METHOD);
for (int i = 1; i <= rows ; ++i) {
for (guint32 i = 1; i <= rows ; ++i) {
guint32 cols [MONO_METHOD_SIZE];
mono_metadata_decode_row_raw (&image_dmeta->tables [MONO_TABLE_METHOD], i - 1, cols, MONO_METHOD_SIZE);
const char *name = mono_metadata_string_heap (image_base, cols [MONO_METHOD_NAME]);
Expand All @@ -1004,7 +1002,7 @@ dump_update_summary (MonoImage *image_base, MonoImage *image_dmeta)
mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_METADATA_UPDATE, "================================");

rows = mono_image_get_table_rows (image_base, MONO_TABLE_STANDALONESIG);
for (int i = 1; i <= rows; ++i) {
for (guint32 i = 1; i <= rows; ++i) {
guint32 cols [MONO_STAND_ALONE_SIGNATURE_SIZE];
mono_metadata_decode_row (&image_base->tables [MONO_TABLE_STANDALONESIG], i - 1, cols, MONO_STAND_ALONE_SIGNATURE_SIZE);
mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_METADATA_UPDATE, "base standalonesig i=%d (token=0x%08x) -> 0x%08x", i, MONO_TOKEN_SIGNATURE | i, cols [MONO_STAND_ALONE_SIGNATURE]);
Expand All @@ -1014,7 +1012,7 @@ dump_update_summary (MonoImage *image_base, MonoImage *image_dmeta)
mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_METADATA_UPDATE, "--------------------------------");

rows = mono_image_get_table_rows (image_dmeta, MONO_TABLE_STANDALONESIG);
for (int i = 1; i <= rows; ++i) {
for (guint32 i = 1; i <= rows; ++i) {
guint32 cols [MONO_STAND_ALONE_SIGNATURE_SIZE];
mono_metadata_decode_row_raw (&image_dmeta->tables [MONO_TABLE_STANDALONESIG], i - 1, cols, MONO_STAND_ALONE_SIGNATURE_SIZE);
mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_METADATA_UPDATE, "dmeta standalonesig i=%d (token=0x%08x) -> 0x%08x", i, MONO_TOKEN_SIGNATURE | i, cols [MONO_STAND_ALONE_SIGNATURE]);
Expand Down
4 changes: 4 additions & 0 deletions src/mono/mono/eglib/glib.h
Original file line number Diff line number Diff line change
Expand Up @@ -1406,6 +1406,8 @@ __CAST_PTRTYPE_TO_UTYPE(gintptr, gulong, ULONG_MAX)
__CAST_PTRTYPE_TO_STYPE(gintptr, gint, INT_MIN, INT_MAX)
__CAST_PTRTYPE_TO_UTYPE(gintptr, guint, UINT_MAX)

__CAST_PTRTYPE_TO_UTYPE(gintptr, gsize, SIZE_MAX)

__CAST_PTRTYPE_TO_STYPE(guintptr, gint32, INT32_MIN, INT32_MAX)
__CAST_PTRTYPE_TO_UTYPE(guintptr, guint32, UINT32_MAX)
__CAST_PTRTYPE_TO_STYPE(guintptr, gint16, INT16_MIN, INT16_MAX)
Expand Down Expand Up @@ -1588,6 +1590,8 @@ __CAST_UTYPE_TO_STYPE(gunichar, gchar, CHAR_MIN, CHAR_MAX)
#define GINTPTR_TO_INT(v) G_CAST_PTRTYPE_TO_STYPE(gintptr, gint, v)
#define GINTPTR_TO_UINT(v) G_CAST_PTRTYPE_TO_UTYPE(gintptr, guint, v)

#define GINTPTR_TO_SIZE(v) G_CAST_PTRTYPE_TO_UTYPE(gintptr, gsize, v)

#define GUINTPTR_TO_INT32(v) G_CAST_PTRTYPE_TO_STYPE(guintptr, gint32, v)
#define GUINTPTR_TO_UINT32(v) G_CAST_PTRTYPE_TO_UTYPE(guintptr, guint32, v)

Expand Down
2 changes: 1 addition & 1 deletion src/mono/mono/metadata/assembly-load-context.c
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ ves_icall_System_Runtime_Loader_AssemblyLoadContext_InternalGetLoadedAssemblies

MonoArrayHandle res = mono_array_new_handle (mono_class_get_assembly_class (), assemblies->len, error);
goto_if_nok (error, leave);
for (int i = 0; i < assemblies->len; ++i) {
for (guint i = 0; i < assemblies->len; ++i) {
if (!add_assembly_to_array (res, i, (MonoAssembly *)g_ptr_array_index (assemblies, i), error))
goto leave;
}
Expand Down
3 changes: 1 addition & 2 deletions src/mono/mono/metadata/assembly.c
Original file line number Diff line number Diff line change
Expand Up @@ -2915,9 +2915,8 @@ mono_assembly_release_gc_roots (MonoAssembly *assembly)
return;

if (assembly_is_dynamic (assembly)) {
int i;
MonoDynamicImage *dynimg = (MonoDynamicImage *)assembly->image;
for (i = 0; i < dynimg->image.module_count; ++i)
for (guint32 i = 0; i < dynimg->image.module_count; ++i)
mono_dynamic_image_release_gc_roots ((MonoDynamicImage *)dynimg->image.modules [i]);
mono_dynamic_image_release_gc_roots (dynimg);
}
Expand Down
15 changes: 5 additions & 10 deletions src/mono/mono/metadata/debug-helpers.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,6 @@ mono_custom_modifiers_get_desc (GString *res, const MonoType *type, gboolean inc
void
mono_type_get_desc (GString *res, MonoType *type, gboolean include_namespace)
{
int i;

switch (type->type) {
case MONO_TYPE_VOID:
g_string_append (res, "void"); break;
Expand Down Expand Up @@ -177,7 +175,7 @@ mono_type_get_desc (GString *res, MonoType *type, gboolean include_namespace)
case MONO_TYPE_ARRAY:
mono_type_get_desc (res, &type->data.array->eklass->_byval_arg, include_namespace);
g_string_append_c (res, '[');
for (i = 1; i < type->data.array->rank; ++i)
for (guint8 i = 1; i < type->data.array->rank; ++i)
g_string_append_c (res, ',');
g_string_append_c (res, ']');
break;
Expand All @@ -196,7 +194,7 @@ mono_type_get_desc (GString *res, MonoType *type, gboolean include_namespace)
g_string_append (res, "<");
context = &type->data.generic_class->context;
if (context->class_inst) {
for (i = 0; i < context->class_inst->type_argc; ++i) {
for (guint i = 0; i < context->class_inst->type_argc; ++i) {
if (i > 0)
g_string_append (res, ", ");
mono_type_get_desc (res, context->class_inst->type_argv [i], include_namespace);
Expand All @@ -205,7 +203,7 @@ mono_type_get_desc (GString *res, MonoType *type, gboolean include_namespace)
if (context->method_inst) {
if (context->class_inst)
g_string_append (res, "; ");
for (i = 0; i < context->method_inst->type_argc; ++i) {
for (guint i = 0; i < context->method_inst->type_argc; ++i) {
if (i > 0)
g_string_append (res, ", ");
mono_type_get_desc (res, context->method_inst->type_argv [i], include_namespace);
Expand Down Expand Up @@ -305,9 +303,7 @@ mono_signature_full_name (MonoMethodSignature *sig)
void
mono_ginst_get_desc (GString *str, MonoGenericInst *ginst)
{
int i;

for (i = 0; i < ginst->type_argc; ++i) {
for (guint i = 0; i < ginst->type_argc; ++i) {
if (i > 0)
g_string_append (str, ", ");
mono_type_get_desc (str, ginst->type_argv [i], TRUE);
Expand Down Expand Up @@ -599,7 +595,6 @@ mono_method_desc_search_in_image (MonoMethodDesc *desc, MonoImage *image)
MonoClass *klass;
const MonoTableInfo *methods;
MonoMethod *method;
int i;

/* Handle short names for system classes */
if (!desc->name_space && image == mono_defaults.corlib) {
Expand All @@ -618,7 +613,7 @@ mono_method_desc_search_in_image (MonoMethodDesc *desc, MonoImage *image)
/* FIXME: Is this call necessary? We don't use its result. */
mono_image_get_table_info (image, MONO_TABLE_TYPEDEF);
methods = mono_image_get_table_info (image, MONO_TABLE_METHOD);
for (i = 0; i < mono_table_info_get_rows (methods); ++i) {
for (guint32 i = 0; i < mono_table_info_get_rows (methods); ++i) {
ERROR_DECL (error);
guint32 token = mono_metadata_decode_row_col (methods, i, MONO_METHOD_NAME);
const char *n = mono_metadata_string_heap (image, token);
Expand Down
9 changes: 5 additions & 4 deletions src/mono/mono/metadata/debug-mono-ppdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,8 @@ mono_ppdb_lookup_location_internal (MonoImage *image, int idx, uint32_t offset,
const char *ptr;
const char *end;
char *docname = NULL;
int size, docidx, iloffset, delta_il, delta_lines, delta_cols, start_line, start_col, adv_line, adv_col;
int size, docidx, delta_lines, delta_cols, start_line, start_col, adv_line, adv_col;
guint32 iloffset;
gboolean first = TRUE, first_non_hidden = TRUE;
MonoDebugSourceLocation *location;

Expand All @@ -386,7 +387,7 @@ mono_ppdb_lookup_location_internal (MonoImage *image, int idx, uint32_t offset,
start_line = 0;
start_col = 0;
while (ptr < end) {
delta_il = mono_metadata_decode_value (ptr, &ptr);
guint32 delta_il = mono_metadata_decode_value (ptr, &ptr);
if (!first && delta_il == 0) {
/* document-record */
docidx = mono_metadata_decode_value (ptr, &ptr);
Expand Down Expand Up @@ -743,8 +744,8 @@ mono_ppdb_lookup_locals (MonoDebugMethodInfo *minfo)
* We use this to pass context information to the row locator
*/
typedef struct {
int idx; /* The index that we are trying to locate */
int col_idx; /* The index in the row where idx may be stored */
guint32 idx; /* The index that we are trying to locate */
guint32 col_idx; /* The index in the row where idx may be stored */
MonoTableInfo *t; /* pointer to the table */
guint32 result;
} locator_t;
Expand Down
3 changes: 1 addition & 2 deletions src/mono/mono/metadata/dynamic-image.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,12 @@ MonoImage *
mono_find_dynamic_image_owner (void *ptr)
{
MonoImage *owner = NULL;
int i;

dynamic_images_lock ();

if (dynamic_images)
{
for (i = 0; !owner && i < dynamic_images->len; ++i) {
for (guint i = 0; !owner && i < dynamic_images->len; ++i) {
MonoImage *image = (MonoImage *)g_ptr_array_index (dynamic_images, i);
if (mono_mempool_contains_addr (image->mempool, ptr))
owner = image;
Expand Down
4 changes: 2 additions & 2 deletions src/mono/mono/metadata/dynamic-stream.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ mono_dynstream_init (MonoDynamicStream *sh)
}

static void
make_room_in_stream (MonoDynamicStream *stream, int size)
make_room_in_stream (MonoDynamicStream *stream, guint32 size)
{
MONO_REQ_GC_NEUTRAL_MODE;

Expand Down Expand Up @@ -60,7 +60,7 @@ mono_dynstream_insert_string (MonoDynamicStream *sh, const char *str)
len = strlen (str) + 1;
idx = sh->index;

make_room_in_stream (sh, (int)(idx + len));
make_room_in_stream (sh, idx + GSIZE_TO_UINT32(len));

/*
* We strdup the string even if we already copy them in sh->data
Expand Down
5 changes: 2 additions & 3 deletions src/mono/mono/metadata/exception.c
Original file line number Diff line number Diff line change
Expand Up @@ -1328,7 +1328,6 @@ mono_error_set_field_missing (MonoError *error, MonoClass *klass, const char *fi
void
mono_error_set_method_missing (MonoError *error, MonoClass *klass, const char *method_name, MonoMethodSignature *sig, const char *reason, ...)
{
int i;
char *result;
GString *res;

Expand Down Expand Up @@ -1361,7 +1360,7 @@ mono_error_set_method_missing (MonoError *error, MonoClass *klass, const char *m
if (sig) {
if (sig->generic_param_count) {
g_string_append_c (res, '<');
for (i = 0; i < sig->generic_param_count; ++i) {
for (guint i = 0; i < sig->generic_param_count; ++i) {
if (i > 0)
g_string_append (res, ",");
g_string_append_printf (res, "!%d", i);
Expand All @@ -1370,7 +1369,7 @@ mono_error_set_method_missing (MonoError *error, MonoClass *klass, const char *m
}

g_string_append_c (res, '(');
for (i = 0; i < sig->param_count; ++i) {
for (guint16 i = 0; i < sig->param_count; ++i) {
if (i > 0)
g_string_append_c (res, ',');
mono_type_get_desc (res, sig->params [i], TRUE);
Expand Down
4 changes: 2 additions & 2 deletions src/mono/mono/metadata/image.c
Original file line number Diff line number Diff line change
Expand Up @@ -2772,7 +2772,7 @@ mono_image_get_table_info (MonoImage *image, int table_id)
/**
* mono_image_get_table_rows:
*/
int
guint32
mono_image_get_table_rows (MonoImage *image, int table_id)
{
if (table_id < 0 || table_id >= MONO_TABLE_NUM)
Expand All @@ -2783,7 +2783,7 @@ mono_image_get_table_rows (MonoImage *image, int table_id)
/**
* mono_table_info_get_rows:
*/
int
guint32
mono_table_info_get_rows (const MonoTableInfo *table)
{
return table_info_get_rows (table);
Expand Down
3 changes: 1 addition & 2 deletions src/mono/mono/metadata/sre-encode.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ encode_generic_class (MonoDynamicImage *assembly, MonoGenericClass *gclass, SigB
{
MONO_REQ_GC_NEUTRAL_MODE;

int i;
MonoGenericInst *class_inst;
MonoClass *klass;

Expand All @@ -147,7 +146,7 @@ encode_generic_class (MonoDynamicImage *assembly, MonoGenericClass *gclass, SigB
sigbuffer_add_value (buf, mono_dynimage_encode_typedef_or_ref_full (assembly, m_class_get_byval_arg (klass), FALSE));

sigbuffer_add_value (buf, class_inst->type_argc);
for (i = 0; i < class_inst->type_argc; ++i)
for (guint i = 0; i < class_inst->type_argc; ++i)
encode_type (assembly, class_inst->type_argv [i], buf);

}
Expand Down
9 changes: 3 additions & 6 deletions src/mono/mono/mini/alias-analysis.c
Original file line number Diff line number Diff line change
Expand Up @@ -321,14 +321,11 @@ lower_memory_access (MonoCompile *cfg)
static gboolean
recompute_aliased_variables (MonoCompile *cfg, int *restored_vars)
{
int i;
MonoBasicBlock *bb;
MonoInst *ins;
int kills = 0;
int adds = 0;
*restored_vars = 0;

for (i = 0; i < cfg->num_varinfo; i++) {
for (guint i = 0; i < cfg->num_varinfo; i++) {
MonoInst *var = cfg->varinfo [i];
if (var->flags & MONO_INST_INDIRECT) {
if (cfg->verbose_level > 2) {
Expand All @@ -342,8 +339,8 @@ recompute_aliased_variables (MonoCompile *cfg, int *restored_vars)
if (!kills)
return FALSE;

for (bb = cfg->bb_entry; bb; bb = bb->next_bb) {
for (ins = bb->code; ins; ins = ins->next) {
for (MonoBasicBlock *bb = cfg->bb_entry; bb; bb = bb->next_bb) {
for (MonoInst *ins = bb->code; ins; ins = ins->next) {
if (ins->opcode == OP_LDADDR) {
MonoInst *var;

Expand Down
3 changes: 1 addition & 2 deletions src/mono/mono/mini/branch-opts.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ mono_branch_optimize_exception_target (MonoCompile *cfg, MonoBasicBlock *bb, con
MonoMethodHeader *header = cfg->header;
MonoExceptionClause *clause;
MonoClass *exclass;
int i;

if (!(cfg->opt & MONO_OPT_EXCEPTION))
return NULL;
Expand All @@ -51,7 +50,7 @@ mono_branch_optimize_exception_target (MonoCompile *cfg, MonoBasicBlock *bb, con

exclass = mono_class_load_from_name (mono_get_corlib (), "System", exname);
/* search for the handler */
for (i = 0; i < header->num_clauses; ++i) {
for (guint i = 0; i < header->num_clauses; ++i) {
clause = &header->clauses [i];
if (MONO_OFFSET_IN_CLAUSE (clause, bb->real_offset)) {
if (clause->flags == MONO_EXCEPTION_CLAUSE_NONE && clause->data.catch_class && mono_class_is_assignable_from_internal (clause->data.catch_class, exclass)) {
Expand Down
Loading