[runtime] Fix printf-like format warnings.
authorAleksey Kliger <aleksey@xamarin.com>
Fri, 30 Sep 2016 22:28:18 +0000 (18:28 -0400)
committerAleksey Kliger <aleksey@xamarin.com>
Fri, 30 Sep 2016 22:54:17 +0000 (18:54 -0400)
13 files changed:
mono/io-layer/processes.c
mono/metadata/class.c
mono/metadata/loader.c
mono/metadata/marshal.c
mono/metadata/object.c
mono/metadata/security-core-clr.c
mono/metadata/threadpool-ms.c
mono/metadata/w32mutex-unix.c
mono/metadata/w32semaphore-unix.c
mono/mini/mini.c
mono/utils/checked-build.h
mono/utils/mono-threads-coop.c
mono/utils/w32handle.c

index 35cd67eb5c0d60435aad18ee1a774c2ee52f94b9..6e4d6d578f6e54077e8873435e5b3576b7238085 100644 (file)
@@ -2806,7 +2806,7 @@ process_wait (gpointer handle, guint32 timeout, gboolean *alerted)
        while (1) {
                if (timeout != INFINITE) {
                        MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s (%p, %u): waiting on semaphore for %li ms...", 
-                                  __func__, handle, timeout, (timeout - (now - start)));
+                                   __func__, handle, timeout, (long)(timeout - (now - start)));
                        ret = mono_os_sem_timedwait (&mp->exit_sem, (timeout - (now - start)), alerted ? MONO_SEM_FLAGS_ALERTABLE : MONO_SEM_FLAGS_NONE);
                } else {
                        MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s (%p, %u): waiting on semaphore forever...", 
index e1fc5acb86b5ff998a7b098a507f737ff248e88b..ed14162510d11badbc487d7b615c825375583c8a 100644 (file)
@@ -1391,7 +1391,7 @@ mono_error_set_for_class_failure (MonoError *oerror, MonoClass *klass)
                return;
        }
        case MONO_EXCEPTION_INVALID_PROGRAM: {
-               mono_error_set_invalid_program (oerror, (const char *)exception_data);
+               mono_error_set_invalid_program (oerror, "%s", (const char *)exception_data);
                return;
        }
        case MONO_EXCEPTION_MISSING_METHOD:
@@ -5696,7 +5696,7 @@ static void
 mono_class_set_failure_and_error (MonoClass *klass, MonoError *error, const char *msg)
 {
        mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, mono_image_strdup (klass->image, msg));
-       mono_error_set_type_load_class (error, klass, msg);
+       mono_error_set_type_load_class (error, klass, "%s", msg);
 }
 
 /**
index e2a91f0975fb4ee6dea5c401e23e545c8038dad3..3d85497bfe0a094a8154c6277ba693e8a910f157 100644 (file)
@@ -194,7 +194,7 @@ field_from_memberref (MonoImage *image, guint32 token, MonoClass **retklass,
        fname = mono_metadata_string_heap (image, cols [MONO_MEMBERREF_NAME]);
 
        if (!mono_verifier_verify_memberref_field_signature (image, cols [MONO_MEMBERREF_SIGNATURE], NULL)) {
-               mono_error_set_bad_image (error, image, "Bad field '%s' signature 0x%08x", class_index, token);
+               mono_error_set_bad_image (error, image, "Bad field '%u' signature 0x%08x", class_index, token);
                return NULL;
        }
 
@@ -209,7 +209,7 @@ field_from_memberref (MonoImage *image, guint32 token, MonoClass **retklass,
                klass = mono_class_get_and_inflate_typespec_checked (image, MONO_TOKEN_TYPE_SPEC | nindex, context, error);
                break;
        default:
-               mono_error_set_bad_image (error, image, "Bad field field '%s' signature 0x%08x", class_index, token);
+               mono_error_set_bad_image (error, image, "Bad field field '%u' signature 0x%08x", class_index, token);
        }
 
        if (!klass)
index d12e345ca26f4f399373e70077e13595d9a9160d..fd20aea402f3651fcaa22801629447222f2de0ce 100644 (file)
@@ -10531,7 +10531,7 @@ mono_marshal_alloc (gulong size, MonoError *error)
 #else
        res = g_try_malloc ((gulong)size);
        if (!res)
-               mono_error_set_out_of_memory (error, "Could not allocate %i bytes", size);
+               mono_error_set_out_of_memory (error, "Could not allocate %lu bytes", size);
 #endif
        return res;
 }
index 9db69581fbcc77704b0230f94bf300466255d509..057e858b882fe4d2e135185473d69afa2e795eb1 100644 (file)
@@ -5822,7 +5822,7 @@ mono_array_new_full_checked (MonoDomain *domain, MonoClass *array_class, uintptr
                o = (MonoObject *)mono_gc_alloc_vector (vtable, byte_len, len);
 
        if (G_UNLIKELY (!o)) {
-               mono_error_set_out_of_memory (error, "Could not allocate %i bytes", byte_len);
+               mono_error_set_out_of_memory (error, "Could not allocate %zd bytes", (gsize) byte_len);
                return NULL;
        }
 
@@ -5936,7 +5936,7 @@ mono_array_new_specific_checked (MonoVTable *vtable, uintptr_t n, MonoError *err
        o = (MonoObject *)mono_gc_alloc_vector (vtable, byte_len, n);
 
        if (G_UNLIKELY (!o)) {
-               mono_error_set_out_of_memory (error, "Could not allocate %i bytes", byte_len);
+               mono_error_set_out_of_memory (error, "Could not allocate %zd bytes", (gsize) byte_len);
                return NULL;
        }
 
@@ -6094,7 +6094,7 @@ mono_string_new_size_checked (MonoDomain *domain, gint32 len, MonoError *error)
        s = (MonoString *)mono_gc_alloc_string (vtable, size, len);
 
        if (G_UNLIKELY (!s)) {
-               mono_error_set_out_of_memory (error, "Could not allocate %i bytes", size);
+               mono_error_set_out_of_memory (error, "Could not allocate %zd bytes", size);
                return NULL;
        }
 
index fbbc45dd6415a6b01ffd1966d0061acc09ba09df..b228c6295afbec039774e955d7a315558c68614e 100644 (file)
@@ -165,7 +165,7 @@ set_type_load_exception_type (const char *format, MonoClass *klass)
        g_free (parent_name);
        g_free (type_name);
        
-       mono_trace (G_LOG_LEVEL_WARNING, MONO_TRACE_SECURITY, message);
+       mono_trace (G_LOG_LEVEL_WARNING, MONO_TRACE_SECURITY, "%s", message);
        mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, message);
        // note: do not free string given to mono_class_set_failure
 }
@@ -188,7 +188,7 @@ set_type_load_exception_methods (const char *format, MonoMethod *override, MonoM
        g_free (base_name);
        g_free (method_name);
 
-       mono_trace (G_LOG_LEVEL_WARNING, MONO_TRACE_SECURITY, message);
+       mono_trace (G_LOG_LEVEL_WARNING, MONO_TRACE_SECURITY, "%s", message);
        mono_class_set_failure (override->klass, MONO_EXCEPTION_TYPE_LOAD, message);
        // note: do not free string given to mono_class_set_failure
 }
@@ -561,7 +561,7 @@ get_argument_exception (const char *format, MonoMethod *caller, MonoMethod *call
        g_free (callee_name);
        g_free (caller_name);
 
-       mono_trace (G_LOG_LEVEL_WARNING, MONO_TRACE_SECURITY, message);
+       mono_trace (G_LOG_LEVEL_WARNING, MONO_TRACE_SECURITY, "%s", message);
        ex = mono_get_exception_argument ("method", message);
        g_free (message);
 
@@ -586,7 +586,7 @@ get_field_access_exception (const char *format, MonoMethod *caller, MonoClassFie
        g_free (field_name);
        g_free (caller_name);
 
-       mono_trace (G_LOG_LEVEL_WARNING, MONO_TRACE_SECURITY, message);
+       mono_trace (G_LOG_LEVEL_WARNING, MONO_TRACE_SECURITY, "%s", message);
        ex = mono_get_exception_field_access_msg (message);
        g_free (message);
 
@@ -611,7 +611,7 @@ get_method_access_exception (const char *format, MonoMethod *caller, MonoMethod
        g_free (callee_name);
        g_free (caller_name);
 
-       mono_trace (G_LOG_LEVEL_WARNING, MONO_TRACE_SECURITY, message);
+       mono_trace (G_LOG_LEVEL_WARNING, MONO_TRACE_SECURITY, "%s", message);
        ex = mono_get_exception_method_access_msg (message);
        g_free (message);
 
index 7849d4554f5646220aa302bcc00ae013dfcd837d..d22470415e84e1891759e5a31df748eacde76531 100644 (file)
@@ -658,7 +658,7 @@ worker_thread (gpointer data)
                tpdomain->outstanding_request --;
                g_assert (tpdomain->outstanding_request >= 0);
 
-               mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_THREADPOOL, "[%p] worker running in domain %p",
+               mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_THREADPOOL, "[%p] worker running in domain %p (outstanding requests %d) ",
                        mono_native_thread_id_get (), tpdomain->domain, tpdomain->outstanding_request);
 
                g_assert (tpdomain->domain);
@@ -778,7 +778,7 @@ worker_try_create (void)
        if ((thread = mono_thread_create_internal (mono_get_root_domain (), worker_thread, NULL, TRUE, 0, &error)) != NULL) {
                threadpool->worker_creation_current_count += 1;
 
-               mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_THREADPOOL, "[%p] try create worker, created %p, now = %d count = %d", mono_native_thread_id_get (), thread->tid, now, threadpool->worker_creation_current_count);
+               mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_THREADPOOL, "[%p] try create worker, created %p, now = %d count = %d", mono_native_thread_id_get (), GUINT_TO_POINTER(thread->tid), now, threadpool->worker_creation_current_count);
                mono_coop_mutex_unlock (&threadpool->worker_creation_lock);
                return TRUE;
        }
index a995eeb3640c44159e9c9534f70f7373a7e577f0..fbf1f6177a8bcb06ce95bf8b5e94b8785144b0f3 100644 (file)
@@ -412,7 +412,7 @@ ves_icall_System_Threading_Mutex_ReleaseMutex_internal (gpointer handle)
                ret = FALSE;
 
                mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: we don't own %s handle %p (owned by %ld, me %ld)",
-                       __func__, mono_w32handle_ops_typename (type), handle, mutex_handle->tid, tid);
+                           __func__, mono_w32handle_ops_typename (type), handle, (long)mutex_handle->tid, (long)tid);
        } else {
                ret = TRUE;
 
index 1f99d8fdff35769bebde8d60c0a742256be27a7d..21e7921127aae4b0c69731225cecaeef9d58e4f8 100644 (file)
@@ -184,7 +184,7 @@ namedsem_create (gint32 initial, gint32 max, const gunichar2 *name)
        gchar *utf8_name;
 
        mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: creating %s handle, initial %d max %d name \"%s\"",
-               __func__, mono_w32handle_ops_typename (MONO_W32HANDLE_NAMEDSEM), initial, max, name);
+                   __func__, mono_w32handle_ops_typename (MONO_W32HANDLE_NAMEDSEM), initial, max, (const char*)name);
 
        /* w32 seems to guarantee that opening named objects can't race each other */
        mono_w32handle_namespace_lock ();
index ac92addeac2ad6de6f3fe5228a5bf6833bddf549..f6ce09236813eef8630c1ccb9a30322eeaa4b715 100644 (file)
@@ -1052,7 +1052,7 @@ mini_method_verify (MonoCompile *cfg, MonoMethod *method, gboolean fail_compile)
                                        else if (info->exception_type == MONO_EXCEPTION_FIELD_ACCESS)
                                                mono_error_set_generic_error (&cfg->error, "System", "FieldAccessException", "%s", msg);
                                        else if (info->exception_type == MONO_EXCEPTION_UNVERIFIABLE_IL)
-                                               mono_error_set_generic_error (&cfg->error, "System.Security", "VerificationException", msg);
+                                               mono_error_set_generic_error (&cfg->error, "System.Security", "VerificationException", "%s", msg);
                                        if (!mono_error_ok (&cfg->error)) {
                                                mono_cfg_set_exception (cfg, MONO_EXCEPTION_MONO_ERROR);
                                                g_free (msg);
@@ -4053,7 +4053,7 @@ void
 mono_cfg_set_exception_invalid_program (MonoCompile *cfg, char *msg)
 {
        mono_cfg_set_exception (cfg, MONO_EXCEPTION_MONO_ERROR);
-       mono_error_set_generic_error (&cfg->error, "System", "InvalidProgramException", msg);
+       mono_error_set_generic_error (&cfg->error, "System", "InvalidProgramException", "%s", msg);
 }
 
 #endif /* DISABLE_JIT */
index b1c4b544d778174caee6468793ed922a33c57f2e..3dcbe286cca7ee4da0924ddf14f8e010e40607b7 100644 (file)
@@ -12,6 +12,7 @@
 
 #include <config.h>
 #include <mono/utils/atomic.h>
+#include <mono/utils/mono-compiler.h>
 #include <mono/utils/mono-publib.h>
 
 typedef enum {
@@ -207,7 +208,7 @@ void check_metadata_store_local(void *from, void *to);
 
 void checked_build_thread_transition(const char *transition, void *info, int from_state, int suspend_count, int next_state, int suspend_count_delta);
 
-G_GNUC_NORETURN void mono_fatal_with_history(const char *msg, ...) MONO_ATTR_FORMAT_PRINTF(1,2);
+G_GNUC_NORETURN MONO_ATTR_FORMAT_PRINTF(1,2) void mono_fatal_with_history(const char *msg, ...);
 
 #else
 
index 9bfbdc51682b2db4fa1b2f94e30a6028ae7e2764..3416fe682071f24cc15d7f0898345600b0bf0dd9 100644 (file)
@@ -70,7 +70,7 @@ coop_tls_pop (gpointer received_cookie)
 
        stack = mono_native_tls_get_value (coop_reset_count_stack_key);
        if (!stack || 0 == stack->len)
-               mono_fatal_with_history ("Received cookie %p but found no stack at all, %x\n", received_cookie);
+               mono_fatal_with_history ("Received cookie %p but found no stack at all\n", received_cookie);
 
        expected_cookie = g_array_index (stack, gpointer, stack->len - 1);
        stack->len --;
index d9957cef896a9e8faa99a2b3607113d7631c4b9e..bd82fb5578ddf4add10e219f7bbcc8ae7e73ad35 100644 (file)
@@ -1295,7 +1295,7 @@ mono_w32handle_wait_multiple (gpointer *handles, gsize nhandles, gboolean waital
        alerted = FALSE;
 
        if (nhandles > MONO_W32HANDLE_MAXIMUM_WAIT_OBJECTS) {
-               mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_W32HANDLE, "%s: too many handles: %d",
+               mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_W32HANDLE, "%s: too many handles: %zd",
                        __func__, nhandles);
 
                return MONO_W32HANDLE_WAIT_RET_FAILED;