[Mono-list] [PATCH] kill warnings part 1
Dennis Haney
davh@davh.dk
01 Jun 2002 23:56:29 +0200
--=-=-=
Paolo Molaro <lupus@ximian.com> writes:
> On 06/01/02 Dennis Haney wrote:
> > I've made a small patch to make most of the mono/mono subdir compile
> > without warnings. Please verify that I've not introduced some strange
> > error. Particularly in the assembly code (a change which actually
> > makes it compile in gcc-3.1).
>
> Well, it seems the build breaker was the atomic.h bits.
;)
> Anyway, I applied some of your fixes.
Thanks.
> The assembly code changes are wrong and have not been applied
> (I fixed the warnings though). An AssemblyName is not the same thing as
> the assembly name: it contains also the info on version, culture etc.
> You can't just ignore all the info and use only the bare string name.
Well, you do ;) The only thing that is being used in the
mono_assembly_load is the name. But I can see I missed the comment
about "later we'll do all the checks" ;)
> > + char *friendly_name;
>
> Thanks for catching this one!
You're welcome ;)
> > --- metadata/metadata.c 31 May 2002 09:50:46 -0000 1.83
> > +++ metadata/metadata.c 1 Jun 2002 00:03:33 -0000
> > @@ -2182,19 +2182,21 @@
> > * Computes an hash value for @t1 to be used in GHashTable.
> > */
> > guint
> > -mono_metadata_type_hash (MonoType *t1)
> > +//mono_metadata_type_hash (const MonoType *t1)
> > +mono_metadata_type_hash (gconstpointer t1)
>
> I prefer keeping the current prototype for type safety and
You wont get typesafety either way, but then I'm changing the other
hash functions to use the right type to!
> adding a cast when the function is used in the hash table creation.
Ok.
Here is the rest of the mono subdir... Only one change I'm in doubt of
is the obj/delegate change in interp.c, AFAI can see they are the
same, but please verify.
--
Dennis
use Inline C => qq{void p(char*g){printf("Just Another %s Hacker\n",g);}};p("Perl");
--=-=-=
Content-Disposition: attachment; filename=warnings_part2.diff
Content-Description: Kill more warnings
? warnings_part2.diff
Index: interpreter/interp.c
===================================================================
RCS file: /mono/mono/mono/interpreter/interp.c,v
retrieving revision 1.198
diff -u -b -B -r1.198 interp.c
--- interpreter/interp.c 31 May 2002 10:31:09 -0000 1.198
+++ interpreter/interp.c 1 Jun 2002 21:52:10 -0000
@@ -689,7 +689,7 @@
im = mono_get_delegate_invoke (frame->method->klass);
msg = arch_method_call_message_new (frame->method, frame->obj, frame->stack_args, im, &async_callback, &state);
- ares = mono_thread_pool_add (delegate, msg, async_callback, state);
+ ares = mono_thread_pool_add (obj, msg, async_callback, state);
frame->retval->data.p = ares;
return;
}
@@ -1053,6 +1053,7 @@
} \
} while (0)
+/* unused
static void
verify_method (MonoMethod *m)
{
@@ -1070,6 +1071,7 @@
G_BREAKPOINT ();
mono_free_verify_list (errors);
}
+*/
#define MYGUINT64_MAX 18446744073709551615UL
#define MYGINT64_MAX 9223372036854775807LL
@@ -1227,7 +1229,7 @@
GSList *finally_ips = NULL;
const unsigned char *endfinally_ip;
register const unsigned char *ip;
- register stackval *sp;
+ register stackval *sp = 0;
void **args_pointers;
guint32 *offsets;
gint il_ins_count = -1;
@@ -3907,7 +3909,6 @@
MonoInvocation *inv;
MonoMethodHeader *hd;
MonoExceptionClause *clause;
- char *message;
MonoObject *ex_obj;
#if DEBUG_INTERP
@@ -3981,7 +3982,7 @@
if (MONO_OFFSET_IN_CLAUSE (clause, ip_offset) && !(MONO_OFFSET_IN_CLAUSE (clause, endfinally_ip - header->code))) {
if (clause->flags == MONO_EXCEPTION_CLAUSE_FINALLY) {
ip = header->code + clause->handler_offset;
- finally_ips = g_slist_append (finally_ips, ip);
+ finally_ips = g_slist_append (finally_ips, (gpointer)ip);
#if DEBUG_INTERP
if (tracing)
g_print ("* Found finally at IL_%04x with exception: %s\n", clause->handler_offset, frame->ex? "yes": "no");
Index: jit/debug-dwarf2.c
===================================================================
RCS file: /mono/mono/mono/jit/debug-dwarf2.c,v
retrieving revision 1.25
diff -u -b -B -r1.25 debug-dwarf2.c
--- jit/debug-dwarf2.c 30 May 2002 14:30:13 -0000 1.25
+++ jit/debug-dwarf2.c 1 Jun 2002 21:52:11 -0000
@@ -176,7 +176,7 @@
static void
dwarf2_write_address (FILE *f, void *address)
{
- fprintf (f, "\t.long 0x%lx\n", address);
+ fprintf (f, "\t.long 0x%p\n", address);
}
static void
Index: jit/linear-scan.c
===================================================================
RCS file: /mono/mono/mono/jit/linear-scan.c,v
retrieving revision 1.4
diff -u -b -B -r1.4 linear-scan.c
--- jit/linear-scan.c 10 May 2002 09:10:54 -0000 1.4
+++ jit/linear-scan.c 1 Jun 2002 21:52:11 -0000
@@ -32,6 +32,7 @@
return mono_bitset_mem_new (mem, max_size, MONO_BITSET_DONT_FREE);
}
+/* unused
static void
mono_bitset_print (MonoBitSet *set)
{
@@ -46,6 +47,7 @@
}
printf ("}");
}
+*/
static void
mono_update_live_range (MonoFlowGraph *cfg, int varnum, int block_num, int tree_pos)
Index: metadata/domain.c
===================================================================
RCS file: /mono/mono/mono/metadata/domain.c,v
retrieving revision 1.6
diff -u -b -B -r1.6 domain.c
--- metadata/domain.c 1 Jun 2002 08:04:04 -0000 1.6
+++ metadata/domain.c 1 Jun 2002 21:52:11 -0000
@@ -388,13 +388,13 @@
return NULL;
mono_domain_lock (domain);
- g_hash_table_insert (domain->assemblies, ass->aname.name, ass);
+ g_hash_table_insert (domain->assemblies, (gpointer)ass->aname.name, ass);
mono_domain_unlock (domain);
/* FIXME: maybe this must be recursive ? */
for (i = 0; (tmp = ass->image->references [i]) != NULL; i++) {
if (!g_hash_table_lookup (domain->assemblies, tmp->aname.name))
- g_hash_table_insert (domain->assemblies, tmp->aname.name, tmp);
+ g_hash_table_insert (domain->assemblies, (gpointer)tmp->aname.name, tmp);
}
return ass;
Index: metadata/loader.c
===================================================================
RCS file: /mono/mono/mono/metadata/loader.c,v
retrieving revision 1.66
diff -u -b -B -r1.66 loader.c
--- metadata/loader.c 31 May 2002 10:14:30 -0000 1.66
+++ metadata/loader.c 1 Jun 2002 21:52:11 -0000
@@ -46,7 +46,7 @@
icall_hash = g_hash_table_new (g_str_hash , g_str_equal);
}
- g_hash_table_insert (icall_hash, g_strdup (name), method);
+ g_hash_table_insert (icall_hash, g_strdup (name), (gpointer)method);
}
static void
Index: metadata/metadata.c
===================================================================
RCS file: /mono/mono/mono/metadata/metadata.c,v
retrieving revision 1.83
diff -u -b -B -r1.83 metadata.c
--- metadata/metadata.c 31 May 2002 09:50:46 -0000 1.83
+++ metadata/metadata.c 1 Jun 2002 21:52:11 -0000
@@ -1102,18 +1102,14 @@
* MonoTypes with modifies are never cached, so we never check or use that field.
*/
static guint
-mono_type_hash (gconstpointer data)
+mono_type_hash (const MonoType *type)
{
- const MonoType *type = (const MonoType *) data;
return type->type | (type->byref << 8) | (type->attrs << 9);
}
static gint
-mono_type_equal (gconstpointer ka, gconstpointer kb)
+mono_type_equal (const MonoType *a, const MonoType *b)
{
- const MonoType *a = (const MonoType *) ka;
- const MonoType *b = (const MonoType *) kb;
-
if (a->type != b->type || a->byref != b->byref || a->attrs != b->attrs || a->pinned != b->pinned)
return 0;
/* need other checks */
@@ -1143,7 +1139,7 @@
if (!type_cache) {
int i;
- type_cache = g_hash_table_new (mono_type_hash, mono_type_equal);
+ type_cache = g_hash_table_new ((GHashFunc)mono_type_hash, (GEqualFunc)mono_type_equal);
for (i = 0; i < NBUILTIN_TYPES (); ++i)
g_hash_table_insert (type_cache, &builtin_types [i], &builtin_types [i]);
@@ -2182,7 +2178,7 @@
* Computes an hash value for @t1 to be used in GHashTable.
*/
guint
-mono_metadata_type_hash (MonoType *t1)
+mono_metadata_type_hash (const MonoType *t1)
{
guint hash = t1->type;
@@ -2208,7 +2204,7 @@
* Returns: #TRUE if @t1 and @t2 are equal.
*/
gboolean
-mono_metadata_type_equal (MonoType *t1, MonoType *t2)
+mono_metadata_type_equal (const MonoType *t1, const MonoType *t2)
{
if (t1->type != t2->type ||
t1->byref != t2->byref)
Index: metadata/metadata.h
===================================================================
RCS file: /mono/mono/mono/metadata/metadata.h,v
retrieving revision 1.56
diff -u -b -B -r1.56 metadata.h
--- metadata/metadata.h 30 May 2002 08:33:27 -0000 1.56
+++ metadata/metadata.h 1 Jun 2002 21:52:11 -0000
@@ -257,8 +257,8 @@
int mono_type_stack_size (MonoType *type,
int *alignment);
-guint mono_metadata_type_hash (MonoType *t1);
-gboolean mono_metadata_type_equal (MonoType *t1, MonoType *t2);
+guint mono_metadata_type_hash (const MonoType *t1);
+gboolean mono_metadata_type_equal (const MonoType *t1, const MonoType *t2);
MonoMethodSignature *mono_metadata_parse_signature (MonoImage *image,
guint32 token);
Index: metadata/mono-config.c
===================================================================
RCS file: /mono/mono/mono/metadata/mono-config.c,v
retrieving revision 1.2
diff -u -b -B -r1.2 mono-config.c
--- metadata/mono-config.c 1 Jun 2002 08:04:04 -0000 1.2
+++ metadata/mono-config.c 1 Jun 2002 21:52:11 -0000
@@ -207,7 +207,7 @@
{
inited = 1;
config_handlers = g_hash_table_new (g_str_hash, g_str_equal);
- g_hash_table_insert (config_handlers, dllmap_handler.element_name, &dllmap_handler);
+ g_hash_table_insert (config_handlers, (gpointer)dllmap_handler.element_name, (gpointer)&dllmap_handler);
}
/* FIXME: error handling */
Index: monograph/monograph.c
===================================================================
RCS file: /mono/mono/mono/monograph/monograph.c,v
retrieving revision 1.8
diff -u -b -B -r1.8 monograph.c
--- monograph/monograph.c 4 May 2002 09:15:44 -0000 1.8
+++ monograph/monograph.c 1 Jun 2002 21:52:12 -0000
@@ -318,12 +318,9 @@
}
static int
-compare_bblock (void *a, void *b)
+compare_bblock (MonoBasicBlock *a, MonoBasicBlock *b)
{
- MonoBasicBlock **ab = a;
- MonoBasicBlock **bb = b;
-
- return (*ab)->cil_code - (*bb)->cil_code;
+ return a->cil_code - b->cil_code;
}
static GPtrArray*
@@ -458,7 +455,7 @@
target = g_new0 (MonoBasicBlock, 1);
target->cil_code = itarget;
g_ptr_array_add (result, target);
- g_hash_table_insert (table, itarget, target);
+ g_hash_table_insert (table, (gpointer)itarget, target);
}
link_bblock (bb, target);
}
@@ -477,7 +474,7 @@
}
g_hash_table_destroy (table);
- qsort (result->pdata, result->len, sizeof (gpointer), compare_bblock);
+ g_ptr_array_sort (result, (GCompareFunc)compare_bblock);
/* skip entry and end */
bb = target = NULL;
for (i = 2; i < result->len; ++i) {
@@ -534,7 +531,7 @@
GList *tmp;
MonoBasicBlock *bb, *target;
MonoMethodHeader *header;
- int i, dfn;
+ int i;
char *code;
header = ((MonoMethodNormal*)method)->header;
Index: os/unix/.cvsignore
===================================================================
RCS file: /mono/mono/mono/os/unix/.cvsignore,v
retrieving revision 1.1
diff -u -b -B -r1.1 .cvsignore
--- os/unix/.cvsignore 18 May 2002 17:32:36 -0000 1.1
+++ os/unix/.cvsignore 1 Jun 2002 21:52:12 -0000
@@ -1,3 +1,4 @@
+.deps
Makefile
Makefile.in
util.o
Index: tests/libtest.c
===================================================================
RCS file: /mono/mono/mono/tests/libtest.c,v
retrieving revision 1.4
diff -u -b -B -r1.4 libtest.c
--- tests/libtest.c 28 Mar 2002 07:18:59 -0000 1.4
+++ tests/libtest.c 1 Jun 2002 21:52:12 -0000
@@ -4,8 +4,19 @@
int f, int g, int h, int i, int j);
short mono_test_many_short_arguments (short a, short b, short c, short d, short e,
short f, short g, short h, short i, short j);
+char mono_test_many_byte_arguments (char a, char b, char c, char d, char e,
+ char f, char g, char h, char i, char j);
+
+int mono_test_puts_static (char *s);
+
+typedef int (*SimpleDelegate) (int a, int b);
+
+int mono_invoke_delegate (SimpleDelegate delegate);
+
+/*
char mono_test_many_char_arguments (char a, char b, char c, char d, char e,
char f, char g, char h, char i, char j);
+*/
int
mono_test_many_int_arguments (int a, int b, int c, int d, int e, int f, int g, int h, int i, int j)
@@ -31,8 +42,6 @@
printf ("TEST %s\n", s);
return 1;
}
-
-typedef int (*SimpleDelegate) (int a, int b);
int
mono_invoke_delegate (SimpleDelegate delegate)
Index: utils/strtod.c
===================================================================
RCS file: /mono/mono/mono/utils/strtod.c,v
retrieving revision 1.1
diff -u -b -B -r1.1 strtod.c
--- utils/strtod.c 13 May 2002 22:43:03 -0000 1.1
+++ utils/strtod.c 1 Jun 2002 21:52:12 -0000
@@ -1922,9 +1922,9 @@
*decpt = 9999;
s =
#ifdef IEEE_Arith
- !word1(d) && !(word0(d) & 0xfffff) ? "Infinity" :
+ !word1(d) && !(word0(d) & 0xfffff) ? (char*)"Infinity" :
#endif
- "NaN";
+ (char*)"NaN";
if (rve)
*rve =
#ifdef IEEE_Arith
@@ -1939,7 +1939,7 @@
#endif
if (!d) {
*decpt = 1;
- s = "0";
+ s = (char*)"0";
if (rve)
*rve = s + 1;
return s;
--=-=-=--