[mono] Fix types for arguments to printf calls (#62796)
authorAlexander Köplinger <alex.koeplinger@outlook.com>
Wed, 15 Dec 2021 01:49:39 +0000 (02:49 +0100)
committerGitHub <noreply@github.com>
Wed, 15 Dec 2021 01:49:39 +0000 (20:49 -0500)
* [mono] Fix types for arguments to printf calls

   These came up while I was using a code scanning tool.

* Fix build

src/mono/mono/component/debugger-state-machine.c
src/mono/mono/mini/interp/transform.c
src/mono/mono/mini/mini-runtime.c
src/mono/mono/sgen/sgen-debug.c
src/mono/mono/sgen/sgen-gc.c
src/mono/mono/utils/mono-threads.c

index c5b96b7..a9a5ebb 100644 (file)
@@ -248,7 +248,7 @@ dump_thread_state (gpointer key, gpointer value, gpointer user_data)
 
        mono_json_writer_indent (data->writer);
        mono_json_writer_object_key(data->writer, "thread_id");
-       mono_json_writer_printf (data->writer, "\"0x%x\",\n", mono_debugger_tls_thread_id (debugger_tls));
+       mono_json_writer_printf (data->writer, "\"0x%x\",\n", (unsigned int) mono_debugger_tls_thread_id (debugger_tls));
 
        mono_json_writer_indent (data->writer);
        mono_json_writer_object_key (data->writer, "thread_state");
@@ -310,7 +310,7 @@ mono_debugger_state (JsonWriter *writer)
 
                        mono_json_writer_indent (writer);
                        mono_json_writer_object_key(writer, "il_offset");
-                       mono_json_writer_printf (writer, "\"0x%x\",\n", bp->il_offset);
+                       mono_json_writer_printf (writer, "\"0x%x\",\n", (unsigned int) bp->il_offset);
 
                        mono_json_writer_indent_pop (writer);
                        mono_json_writer_indent (writer);
@@ -351,7 +351,7 @@ mono_debugger_state (JsonWriter *writer)
 
                mono_json_writer_indent (writer);
                mono_json_writer_object_key(writer, "tid");
-               mono_json_writer_printf (writer, "\"0x%x\",\n", item.tid);
+               mono_json_writer_printf (writer, "\"0x%x\",\n", (unsigned int) item.tid);
 
                mono_json_writer_indent (writer);
                mono_json_writer_object_key(writer, "message");
@@ -359,7 +359,7 @@ mono_debugger_state (JsonWriter *writer)
 
                mono_json_writer_indent (writer);
                mono_json_writer_object_key(writer, "counter");
-               mono_json_writer_printf (writer, "\"%d\"\n", header.counter);
+               mono_json_writer_printf (writer, "\"%ld\"\n", header.counter);
 
                mono_json_writer_indent_pop (writer);
                mono_json_writer_indent (writer);
index 576f5db..96ec25f 100644 (file)
@@ -8713,7 +8713,7 @@ retry:
                                        sregs [0] = sregs [1];
 
                                        if (td->verbose_level) {
-                                               g_print ("Replace ldloca/stfld pair (off %p) :\n\t", ldloca->il_offset);
+                                               g_print ("Replace ldloca/stfld pair (off %p) :\n\t", (void *)(uintptr_t) ldloca->il_offset);
                                                dump_interp_inst (ins);
                                        }
                                        needs_retry = TRUE;
index ac65672..8307847 100644 (file)
@@ -4972,7 +4972,7 @@ mono_runtime_print_stats (void)
 
                g_print ("\nInitialized classes:    %" G_GINT32_FORMAT "\n", mono_stats.generic_class_count);
                g_print ("Inflated types:         %" G_GINT32_FORMAT "\n", mono_stats.inflated_type_count);
-               g_print ("Generics virtual invokes: %ld\n", mono_jit_stats.generic_virtual_invocations);
+               g_print ("Generics virtual invokes: %" G_GINT32_FORMAT "\n", mono_jit_stats.generic_virtual_invocations);
 
                g_print ("Sharable generic methods: %" G_GINT32_FORMAT "\n", mono_stats.generics_sharable_methods);
                g_print ("Unsharable generic methods: %" G_GINT32_FORMAT "\n", mono_stats.generics_unsharable_methods);
index d205602..435a8f3 100644 (file)
@@ -986,7 +986,7 @@ check_reference_for_xdomain (GCObject **ptr, GCObject *obj, MonoDomain *domain)
                mono_error_cleanup (error);
        } else
                str = NULL;
-       g_print ("xdomain reference in %p (%s.%s) at offset %d (%s) to %p (%s.%s) (%s)  -  pointed to by:\n",
+       g_print ("xdomain reference in %p (%s.%s) at offset %zu (%s) to %p (%s.%s) (%s)  -  pointed to by:\n",
                        obj, m_class_get_name_space (obj->vtable->klass), m_class_get_name (obj->vtable->klass),
                        offset, field ? field->name : "",
                        ref, m_class_get_name_space (ref->vtable->klass), m_class_get_name (ref->vtable->klass), str ? str : "");
index 08f192c..b91cef3 100644 (file)
@@ -3580,7 +3580,7 @@ sgen_gc_init (void)
                                if (*opt && mono_gc_parse_environment_string_extract_number (opt, &max_heap_candidate)) {
                                        max_heap = (max_heap_candidate + page_size - 1) & ~(size_t)(page_size - 1);
                                        if (max_heap != max_heap_candidate)
-                                               sgen_env_var_error (MONO_GC_PARAMS_NAME, "Rounding up.", "`max-heap-size` size must be a multiple of %d.", page_size);
+                                               sgen_env_var_error (MONO_GC_PARAMS_NAME, "Rounding up.", "`max-heap-size` size must be a multiple of %zu.", page_size);
                                } else {
                                        sgen_env_var_error (MONO_GC_PARAMS_NAME, NULL, "`max-heap-size` must be an integer.");
                                }
index 1c5a2c0..233e89e 100644 (file)
@@ -298,9 +298,9 @@ dump_threads (void)
                char thread_name [256] = { 0 };
                pthread_getname_np (mono_thread_info_get_tid (info), thread_name, 255);
 
-               g_async_safe_printf ("--thread %p id %p [%p] (%s) state %x  %s\n", info, (gpointer)(gsize) mono_thread_info_get_tid (info), (void*)(size_t)info->native_handle, thread_name, info->thread_state, info == cur ? "GC INITIATOR" : "" );
+               g_async_safe_printf ("--thread %p id %p [%p] (%s) state %x  %s\n", info, (gpointer)(gsize) mono_thread_info_get_tid (info), (void*)(size_t)info->native_handle, thread_name, info->thread_state.raw, info == cur ? "GC INITIATOR" : "" );
 #else
-               g_async_safe_printf ("--thread %p id %p [%p] state %x  %s\n", info, (gpointer)(gsize) mono_thread_info_get_tid (info), (void*)(size_t)info->native_handle, info->thread_state, info == cur ? "GC INITIATOR" : "" );
+               g_async_safe_printf ("--thread %p id %p [%p] state %x  %s\n", info, (gpointer)(gsize) mono_thread_info_get_tid (info), (void*)(size_t)info->native_handle, info->thread_state.raw, info == cur ? "GC INITIATOR" : "" );
 #endif
        } FOREACH_THREAD_SAFE_END
 }