This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Patch for libobjc warnings, one warning needs attention...
- From: "Kaveh R. Ghazi" <ghazi at caip dot rutgers dot edu>
- To: gcc-patches at gcc dot gnu dot org
- Cc: shebs at apple dot com
- Date: Tue, 21 May 2002 14:41:07 -0400 (EDT)
- Subject: Patch for libobjc warnings, one warning needs attention...
The patch below fixes most of the warnings in the libobjc directory.
First, I'll list those warnings that remain:
encoding.c:82: warning: `target_flags' defined but not used
Object.m:273: warning: unused parameter `argFrame'
Object.m:366: warning: unused parameter `aStream'
Object.m:372: warning: unused parameter `aStream'
selector.c:295: warning: comparison between signed and unsigned
selector.c:307: warning: comparison between signed and unsigned
sendmsg.c:107: warning: control reaches end of non-void function
sendmsg.c:291: warning: implicit declaration of function `__objc_generate_gc_type_description'
Of the above, sendmsg.c:107: looks like an actual bug, in that there
is a clause which in fact returns without a value. Someone who
understands the code better should take a look and determine what to
do in that case, e.g. return a value or abort, etc.
Now these are the warnings I fixed, plus the patch. I rebuilt libobjc
and ran make check-objc on mips-irix6.2, there were no failures. Ok
to install on the trunk?
Thanks,
--Kaveh
Fixed warnings:
objc/thr.h:114: warning: function declaration isn't a prototype
archive.c:569: warning: comparison between signed and unsigned
archive.c:598: warning: comparison between signed and unsigned
archive.c:625: warning: comparison between signed and unsigned
archive.c:652: warning: comparison between signed and unsigned
archive.c:677: warning: comparison between signed and unsigned
archive.c:713: warning: comparison between signed and unsigned
archive.c:1045: warning: implicit declaration of function `atoi'
archive.c:1046: warning: subscript has type `char'
archive.c:1142: warning: subscript has type `char'
archive.c:1260: warning: subscript has type `char'
archive.c:1352: warning: subscript has type `char'
archive.c:1431: warning: unused parameter `file'
archive.c:1431: warning: unused parameter `data'
archive.c:1431: warning: unused parameter `len'
archive.c:1438: warning: unused parameter `file'
archive.c:1438: warning: unused parameter `data'
archive.c:1438: warning: unused parameter `len'
objc/thr.h:114: warning: function declaration isn't a prototype
class.c:167: warning: function declaration isn't a prototype
objc/thr.h:114: warning: function declaration isn't a prototype
encoding.c:89: warning: subscript has type `char'
encoding.c:182: warning: subscript has type `char'
encoding.c:194: warning: subscript has type `char'
encoding.c:323: warning: subscript has type `char'
encoding.c:489: warning: subscript has type `char'
encoding.c:501: warning: subscript has type `char'
encoding.c:502: warning: subscript has type `char'
encoding.c:540: warning: subscript has type `char'
encoding.c:772: warning: subscript has type `char'
encoding.c:801: warning: subscript has type `char'
encoding.c:752: warning: unused variable `known_align'
encoding.c:756: warning: `bfld_type' might be used uninitialized in this function
encoding.c:757: warning: `bfld_type_align' might be used uninitialized in this function
encoding.c:757: warning: `bfld_field_size' might be used uninitialized in this function
objc/thr.h:114: warning: function declaration isn't a prototype
gc.c:449: warning: unused parameter `class'
gc.c:453: warning: unused parameter `class'
gc.c:454: warning: unused parameter `ivarname'
gc.c:455: warning: unused parameter `gc_invisible'
objc/thr.h:114: warning: function declaration isn't a prototype
objc/thr.h:114: warning: function declaration isn't a prototype
init.c:332: warning: unused parameter `level'
init.c:345: warning: unused parameter `level'
init.c:801: warning: comparison between signed and unsigned
objc/thr.h:114: warning: function declaration isn't a prototype
objc/thr.h:114: warning: function declaration isn't a prototype
nil_method.c:33: warning: unused parameter `op'
objc/thr.h:114: warning: function declaration isn't a prototype
Object.m:209: warning: comparison between signed and unsigned
objc/thr.h:114: warning: function declaration isn't a prototype
objc/thr.h:114: warning: function declaration isn't a prototype
Protocol.m:64: warning: comparison between signed and unsigned
Protocol.m:91: warning: comparison between signed and unsigned
Protocol.m:117: warning: comparison between signed and unsigned
objc/thr.h:114: warning: function declaration isn't a prototype
sarray.c:265: warning: comparison between signed and unsigned
sarray.c:344: warning: comparison between signed and unsigned
sarray.c:358: warning: comparison between signed and unsigned
sarray.c:411: warning: comparison between signed and unsigned
objc/thr.h:114: warning: function declaration isn't a prototype
selector.c:167: warning: subscript has type `char'
selector.c:168: warning: subscript has type `char'
objc/thr.h:114: warning: function declaration isn't a prototype
sendmsg.c:233: warning: unused parameter `op'
objc/thr.h:114: warning: function declaration isn't a prototype
objc/thr.h:114: warning: function declaration isn't a prototype
Patch:
2002-05-21 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* Object.m: Fix signed/unsigned warning.
* Protocol.m: Likewise.
* archive.c: Always include stdlib.h.
(objc_read_short, objc_read_unsigned_short, objc_read_int,
objc_read_long, __objc_read_nbyte_uint, __objc_read_nbyte_ulong):
Fix signed/unsigned warning.
(objc_write_type, objc_read_type, objc_write_types,
objc_read_types): Ensure ctype 8-bit safety.
(__objc_no_write, __objc_no_read): Mark unused parameters.
* class.c (class_table_setup): Specify void arg.
* encoding.c (atoi, objc_sizeof_type, objc_alignof_type,
objc_skip_typespec, objc_skip_offset,
objc_layout_structure_next_member): Ensure ctype 8-bit safety.
(objc_layout_structure_next_member): Delete unused variable.
Ensure variables are initialized.
* gc.c (__objc_generate_gc_type_description,
class_ivar_set_gcinvisible): Mark unused parameters.
* init.c (__objc_send_load, __objc_destroy_class_tree_node): Mark
unused parameters.
(__objc_init_protocols) Fix signed/unsigned warning.
* nil_method.c (nil_method): Mark unused parameters.
* thr.h (objc_thread_callback): Specify void arg.
* sarray.c (sarray_new, sarray_realloc, sarray_free): Fix
signed/unsigned warning.
(sarray_free): Fix formatting.
* selector.c (sel_types_match): Ensure ctype 8-bit safety.
* sendmsg.c (__objc_init_install_dtable) Mark unused parameters.
diff -rup orig/egcc-CVS20020520/libobjc/Object.m egcc-CVS20020520/libobjc/Object.m
--- orig/egcc-CVS20020520/libobjc/Object.m 2000-07-29 03:09:34.000000000 -0400
+++ egcc-CVS20020520/libobjc/Object.m 2002-05-21 13:48:55.107606000 -0400
@@ -199,7 +199,7 @@ extern int errno;
+ (BOOL) conformsTo: (Protocol*)aProtocol
{
- int i;
+ size_t i;
struct objc_protocol_list* proto_list;
id parent;
diff -rup orig/egcc-CVS20020520/libobjc/Protocol.m egcc-CVS20020520/libobjc/Protocol.m
--- orig/egcc-CVS20020520/libobjc/Protocol.m 1999-09-04 11:09:19.000000000 -0400
+++ egcc-CVS20020520/libobjc/Protocol.m 2002-05-21 13:19:07.851014000 -0400
@@ -53,7 +53,7 @@ struct objc_method_description_list {
- (BOOL) conformsTo: (Protocol *)aProtocolObject
{
- int i;
+ size_t i;
struct objc_protocol_list* proto_list;
if (!strcmp(aProtocolObject->protocol_name, self->protocol_name))
@@ -88,9 +88,10 @@ struct objc_method_description_list {
for (proto_list = protocol_list; proto_list; proto_list = proto_list->next)
{
- for (i=0; i < proto_list->count; i++)
+ size_t j;
+ for (j=0; j < proto_list->count; j++)
{
- if ((result = [proto_list->list[i]
+ if ((result = [proto_list->list[j]
descriptionForInstanceMethod: aSel]))
return result;
}
@@ -114,9 +115,10 @@ struct objc_method_description_list {
for (proto_list = protocol_list; proto_list; proto_list = proto_list->next)
{
- for (i=0; i < proto_list->count; i++)
+ size_t j;
+ for (j=0; j < proto_list->count; j++)
{
- if ((result = [proto_list->list[i]
+ if ((result = [proto_list->list[j]
descriptionForClassMethod: aSel]))
return result;
}
diff -rup orig/egcc-CVS20020520/libobjc/archive.c egcc-CVS20020520/libobjc/archive.c
--- orig/egcc-CVS20020520/libobjc/archive.c 1999-03-26 18:44:04.000000000 -0500
+++ egcc-CVS20020520/libobjc/archive.c 2002-05-21 13:38:54.709989000 -0400
@@ -28,10 +28,7 @@ Boston, MA 02111-1307, USA. */
#include "runtime.h"
#include "typedstream.h"
#include "encoding.h"
-
-#ifdef HAVE_STDLIB_H
#include <stdlib.h>
-#endif
extern int fflush(FILE*);
@@ -566,7 +563,7 @@ objc_read_short (struct objc_typed_strea
{
int pos = 1;
int nbytes = buf[0] & _B_NUMBER;
- if (nbytes > sizeof (short))
+ if (nbytes > (int) sizeof (short))
objc_error(nil, OBJC_ERR_BAD_DATA,
"expected short, got bigger (%dbits)", nbytes*8);
len = (*stream->read)(stream->physical, buf+1, nbytes);
@@ -595,7 +592,7 @@ objc_read_unsigned_short (struct objc_ty
{
int pos = 1;
int nbytes = buf[0] & _B_NUMBER;
- if (nbytes > sizeof (short))
+ if (nbytes > (int) sizeof (short))
objc_error(nil, OBJC_ERR_BAD_DATA,
"expected short, got int or bigger");
len = (*stream->read)(stream->physical, buf+1, nbytes);
@@ -622,7 +619,7 @@ objc_read_int (struct objc_typed_stream*
{
int pos = 1;
int nbytes = buf[0] & _B_NUMBER;
- if (nbytes > sizeof (int))
+ if (nbytes > (int) sizeof (int))
objc_error(nil, OBJC_ERR_BAD_DATA, "expected int, got bigger");
len = (*stream->read)(stream->physical, buf+1, nbytes);
(*value) = 0;
@@ -649,7 +646,7 @@ objc_read_long (struct objc_typed_stream
{
int pos = 1;
int nbytes = buf[0] & _B_NUMBER;
- if (nbytes > sizeof (long))
+ if (nbytes > (int) sizeof (long))
objc_error(nil, OBJC_ERR_BAD_DATA, "expected long, got bigger");
len = (*stream->read)(stream->physical, buf+1, nbytes);
(*value) = 0;
@@ -666,7 +663,8 @@ __inline__ int
__objc_read_nbyte_uint (struct objc_typed_stream* stream,
unsigned int nbytes, unsigned int* val)
{
- int len, pos = 0;
+ int len;
+ unsigned int pos = 0;
unsigned char buf[sizeof(unsigned int)+1];
if (nbytes > sizeof (int))
@@ -702,7 +700,8 @@ int
__objc_read_nbyte_ulong (struct objc_typed_stream* stream,
unsigned int nbytes, unsigned long* val)
{
- int len, pos = 0;
+ int len;
+ unsigned int pos = 0;
unsigned char buf[sizeof(unsigned long)+1];
if (nbytes > sizeof (long))
@@ -1043,7 +1042,7 @@ objc_write_type(TypedStream* stream, con
case _C_ARY_B:
{
int len = atoi(type+1);
- while (isdigit(*++type))
+ while (isdigit((unsigned char)*++type))
;
return objc_write_array (stream, type, len, data);
}
@@ -1139,7 +1138,7 @@ objc_read_type(TypedStream* stream, cons
case _C_ARY_B:
{
int len = atoi(type+1);
- while (isdigit(*++type))
+ while (isdigit((unsigned char)*++type))
;
return objc_read_array (stream, type, len, data);
}
@@ -1257,7 +1256,7 @@ objc_write_types (TypedStream* stream, c
{
int len = atoi(c+1);
const char* t = c;
- while (isdigit(*++t))
+ while (isdigit((unsigned char)*++t))
;
res = objc_write_array (stream, t, len, va_arg(args, void*));
t = objc_skip_typespec (t);
@@ -1349,7 +1348,7 @@ objc_read_types(TypedStream* stream, con
{
int len = atoi(c+1);
const char* t = c;
- while (isdigit(*++t))
+ while (isdigit((unsigned char)*++t))
;
res = objc_read_array (stream, t, len, va_arg(args, void*));
t = objc_skip_typespec (t);
@@ -1428,14 +1427,18 @@ __objc_feof(FILE* file)
}
static int
-__objc_no_write(FILE* file, char* data, int len)
+__objc_no_write(FILE* file __attribute__ ((__unused__)),
+ const char *data __attribute__ ((__unused__)),
+ int len __attribute__ ((__unused__)))
{
objc_error (nil, OBJC_ERR_NO_WRITE, "TypedStream not open for writing");
return 0;
}
static int
-__objc_no_read(FILE* file, char* data, int len)
+__objc_no_read(FILE* file __attribute__ ((__unused__)),
+ const char *data __attribute__ ((__unused__)),
+ int len __attribute__ ((__unused__)))
{
objc_error (nil, OBJC_ERR_NO_READ, "TypedStream not open for reading");
return 0;
diff -rup orig/egcc-CVS20020520/libobjc/class.c egcc-CVS20020520/libobjc/class.c
--- orig/egcc-CVS20020520/libobjc/class.c 2001-10-29 16:31:11.000000000 -0500
+++ egcc-CVS20020520/libobjc/class.c 2002-05-21 13:02:36.862963000 -0400
@@ -163,7 +163,7 @@ static objc_mutex_t __class_table_lock =
/* Setup the table. */
static void
-class_table_setup ()
+class_table_setup (void)
{
/* Start - nothing in the table. */
memset (class_table_array, 0, sizeof(class_node_ptr) * CLASS_TABLE_SIZE);
diff -rup orig/egcc-CVS20020520/libobjc/encoding.c egcc-CVS20020520/libobjc/encoding.c
--- orig/egcc-CVS20020520/libobjc/encoding.c 2002-04-23 07:03:20.000000000 -0400
+++ egcc-CVS20020520/libobjc/encoding.c 2002-05-21 13:27:50.957610000 -0400
@@ -86,7 +86,7 @@ atoi (const char* str)
{
int res = 0;
- while (isdigit (*str))
+ while (isdigit ((unsigned char)*str))
res *= 10, res += (*str++ - '0');
return res;
@@ -179,7 +179,7 @@ objc_sizeof_type (const char* type)
case _C_ARY_B:
{
int len = atoi(type+1);
- while (isdigit(*++type));
+ while (isdigit((unsigned char)*++type));
return len*objc_aligned_size (type);
}
break;
@@ -191,7 +191,7 @@ objc_sizeof_type (const char* type)
int startByte, endByte;
position = atoi (type + 1);
- while (isdigit (*++type));
+ while (isdigit ((unsigned char)*++type));
size = atoi (type + 1);
startByte = position / BITS_PER_UNIT;
@@ -320,7 +320,7 @@ objc_alignof_type(const char* type)
break;
case _C_ARY_B:
- while (isdigit(*++type)) /* do nothing */;
+ while (isdigit((unsigned char)*++type)) /* do nothing */;
return objc_alignof_type (type);
case _C_STRUCT_B:
@@ -486,7 +486,7 @@ objc_skip_typespec (const char* type)
case _C_ARY_B:
/* skip digits, typespec and closing ']' */
- while(isdigit(*++type));
+ while(isdigit((unsigned char)*++type));
type = objc_skip_typespec(type);
if (*type == _C_ARY_E)
return ++type;
@@ -498,8 +498,8 @@ objc_skip_typespec (const char* type)
case _C_BFLD:
/* The new encoding of bitfields is: b 'position' 'type' 'size' */
- while (isdigit (*++type)); /* skip position */
- while (isdigit (*++type)); /* skip type and size */
+ while (isdigit ((unsigned char)*++type)); /* skip position */
+ while (isdigit ((unsigned char)*++type)); /* skip type and size */
return type;
case _C_STRUCT_B:
@@ -537,7 +537,7 @@ inline const char*
objc_skip_offset (const char* type)
{
if (*type == '+') type++;
- while(isdigit(*++type));
+ while(isdigit((unsigned char)*++type));
return type;
}
@@ -749,12 +749,11 @@ objc_layout_structure (const char *type,
BOOL
objc_layout_structure_next_member (struct objc_struct_layout *layout)
{
- register int known_align = layout->record_size;
register int desired_align = 0;
/* The following are used only if the field is a bitfield */
- register const char *bfld_type;
- register int bfld_type_size, bfld_type_align, bfld_field_size;
+ register const char *bfld_type = 0;
+ register int bfld_type_size, bfld_type_align = 0, bfld_field_size = 0;
/* The current type without the type qualifiers */
const char *type;
@@ -769,7 +768,7 @@ objc_layout_structure_next_member (struc
else {
/* Get the bitfield's type */
for (bfld_type = type + 1;
- isdigit(*bfld_type);
+ isdigit((unsigned char)*bfld_type);
bfld_type++)
/* do nothing */;
@@ -798,7 +797,7 @@ objc_layout_structure_next_member (struc
{
desired_align = 1;
/* Skip the bitfield's offset */
- for (bfld_type = type + 1; isdigit(*bfld_type); bfld_type++)
+ for (bfld_type = type + 1; isdigit((unsigned char)*bfld_type); bfld_type++)
/* do nothing */;
bfld_type_size = objc_sizeof_type (bfld_type) * BITS_PER_UNIT;
diff -rup orig/egcc-CVS20020520/libobjc/gc.c egcc-CVS20020520/libobjc/gc.c
--- orig/egcc-CVS20020520/libobjc/gc.c 2001-09-10 16:31:07.000000000 -0400
+++ egcc-CVS20020520/libobjc/gc.c 2002-05-21 13:34:50.334980000 -0400
@@ -446,13 +446,13 @@ class_ivar_set_gcinvisible (Class class,
#else /* !OBJC_WITH_GC */
void
-__objc_generate_gc_type_description (Class class)
+__objc_generate_gc_type_description (Class class __attribute__ ((__unused__)))
{
}
-void class_ivar_set_gcinvisible (Class class,
- const char* ivarname,
- BOOL gc_invisible)
+void class_ivar_set_gcinvisible (Class class __attribute__ ((__unused__)),
+ const char* ivarname __attribute__ ((__unused__)),
+ BOOL gc_invisible __attribute__ ((__unused__)))
{
}
diff -rup orig/egcc-CVS20020520/libobjc/init.c egcc-CVS20020520/libobjc/init.c
--- orig/egcc-CVS20020520/libobjc/init.c 2001-12-17 16:31:17.000000000 -0500
+++ egcc-CVS20020520/libobjc/init.c 2002-05-21 13:40:30.240067000 -0400
@@ -329,7 +329,8 @@ __objc_send_message_in_list (MethodList_
}
static void
-__objc_send_load (objc_class_tree *tree, int level)
+__objc_send_load (objc_class_tree *tree,
+ int level __attribute__ ((__unused__)))
{
static SEL load_sel = 0;
Class class = tree->class;
@@ -342,7 +343,8 @@ __objc_send_load (objc_class_tree *tree,
}
static void
-__objc_destroy_class_tree_node (objc_class_tree *tree, int level)
+__objc_destroy_class_tree_node (objc_class_tree *tree,
+ int level __attribute__ ((__unused__)))
{
objc_free (tree);
}
@@ -776,7 +778,7 @@ static void init_check_module_version(Mo
static void
__objc_init_protocols (struct objc_protocol_list* protos)
{
- int i;
+ size_t i;
static Class proto_class = 0;
if (! protos)
diff -rup orig/egcc-CVS20020520/libobjc/nil_method.c egcc-CVS20020520/libobjc/nil_method.c
--- orig/egcc-CVS20020520/libobjc/nil_method.c 1999-09-04 11:09:19.000000000 -0400
+++ egcc-CVS20020520/libobjc/nil_method.c 2002-05-21 13:40:54.037556000 -0400
@@ -30,7 +30,7 @@ Boston, MA 02111-1307, USA. */
#include "runtime.h"
id
-nil_method(id receiver, SEL op, ...)
+nil_method(id receiver, SEL op __attribute__ ((__unused__)), ...)
{
return receiver;
}
diff -rup orig/egcc-CVS20020520/libobjc/objc/thr.h egcc-CVS20020520/libobjc/objc/thr.h
--- orig/egcc-CVS20020520/libobjc/objc/thr.h 2001-03-14 21:18:09.000000000 -0500
+++ egcc-CVS20020520/libobjc/objc/thr.h 2002-05-21 13:02:21.254628000 -0400
@@ -111,7 +111,7 @@ void objc_thread_remove(void);
it can be informed; for example, the GNUstep Base Library sets it
so it can implement the NSBecomingMultiThreaded notification.
*/
-typedef void (*objc_thread_callback)();
+typedef void (*objc_thread_callback)(void);
objc_thread_callback objc_set_thread_callback(objc_thread_callback func);
/* Backend initialization functions */
diff -rup orig/egcc-CVS20020520/libobjc/sarray.c egcc-CVS20020520/libobjc/sarray.c
--- orig/egcc-CVS20020520/libobjc/sarray.c 2000-07-29 03:10:20.000000000 -0400
+++ egcc-CVS20020520/libobjc/sarray.c 2002-05-21 13:24:27.338368000 -0400
@@ -211,7 +211,7 @@ sarray_new (int size, void* default_elem
size_t num_indices = ((size-1)/BUCKET_SIZE)+1;
struct sbucket ** new_buckets;
#endif
- int counter;
+ size_t counter;
assert(size > 0);
@@ -302,7 +302,7 @@ sarray_realloc(struct sarray* array, int
#endif
- int counter;
+ size_t counter;
assert(newsize > 0);
@@ -382,8 +382,8 @@ sarray_realloc(struct sarray* array, int
/* Free a sparse array allocated with sarray_new */
void
-sarray_free(struct sarray* array) {
-
+sarray_free(struct sarray* array)
+{
#ifdef OBJC_SPARSE3
size_t old_max_index = (array->capacity-1)/INDEX_CAPACITY;
struct sindex ** old_indices;
@@ -391,7 +391,7 @@ sarray_free(struct sarray* array) {
size_t old_max_index = (array->capacity-1)/BUCKET_SIZE;
struct sbucket ** old_buckets;
#endif
- int counter = 0;
+ size_t counter = 0;
assert(array->ref_count != 0); /* Freed multiple times!!! */
diff -rup orig/egcc-CVS20020520/libobjc/selector.c egcc-CVS20020520/libobjc/selector.c
--- orig/egcc-CVS20020520/libobjc/selector.c 1998-09-29 22:13:13.000000000 -0400
+++ egcc-CVS20020520/libobjc/selector.c 2002-05-21 13:01:13.551530000 -0400
@@ -164,8 +164,8 @@ sel_types_match (const char* t1, const c
{
if (*t1 == '+') t1++;
if (*t2 == '+') t2++;
- while (isdigit(*t1)) t1++;
- while (isdigit(*t2)) t2++;
+ while (isdigit((unsigned char)*t1)) t1++;
+ while (isdigit((unsigned char)*t2)) t2++;
/* xxx Remove these next two lines when qualifiers are put in
all selectors, not just Protocol selectors. */
t1 = objc_skip_type_qualifiers(t1);
diff -rup orig/egcc-CVS20020520/libobjc/sendmsg.c egcc-CVS20020520/libobjc/sendmsg.c
--- orig/egcc-CVS20020520/libobjc/sendmsg.c 2001-02-24 01:14:36.000000000 -0500
+++ egcc-CVS20020520/libobjc/sendmsg.c 2002-05-21 13:42:28.957649000 -0400
@@ -230,7 +230,7 @@ __objc_init_dispatch_tables()
dispatch table needs to be installed; thus it is called once
for each class, namely when the very first message is sent to it. */
static void
-__objc_init_install_dtable(id receiver, SEL op)
+__objc_init_install_dtable(id receiver, SEL op __attribute__ ((__unused__)))
{
/* This may happen, if the programmer has taken the address of a
method before the dtable was initialized... too bad for him! */