From 8f8c44cb4fe52e7eb0440abcbc052e0f80cf8037 Mon Sep 17 00:00:00 2001 From: "Kaveh R. Ghazi" Date: Sat, 15 Jun 2002 17:50:14 +0000 Subject: Object.m: Fix signed/unsigned warning. * 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): 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. From-SVN: r54649 --- libobjc/ChangeLog | 30 ++++++++++++++++++++++++++++++ libobjc/Object.m | 2 +- libobjc/Protocol.m | 12 +++++++----- libobjc/archive.c | 33 ++++++++++++++++++--------------- libobjc/class.c | 2 +- libobjc/encoding.c | 24 ++++++++++++------------ libobjc/gc.c | 8 ++++---- libobjc/init.c | 8 +++++--- libobjc/nil_method.c | 2 +- libobjc/objc/thr.h | 2 +- libobjc/sarray.c | 10 +++++----- libobjc/selector.c | 4 ++-- libobjc/sendmsg.c | 2 +- 13 files changed, 88 insertions(+), 51 deletions(-) diff --git a/libobjc/ChangeLog b/libobjc/ChangeLog index a43812a..9e9e7b9 100644 --- a/libobjc/ChangeLog +++ b/libobjc/ChangeLog @@ -1,3 +1,33 @@ +2002-06-15 Kaveh R. Ghazi + + * 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): 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. + 2002-06-09 Andreas Jaeger * encoding.c (objc_layout_structure_next_member): Remove unused diff --git a/libobjc/Object.m b/libobjc/Object.m index f5f3294..fd14cb9 100644 --- a/libobjc/Object.m +++ b/libobjc/Object.m @@ -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 --git a/libobjc/Protocol.m b/libobjc/Protocol.m index 43ba44e..3c18a02 100644 --- a/libobjc/Protocol.m +++ b/libobjc/Protocol.m @@ -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 --git a/libobjc/archive.c b/libobjc/archive.c index 10106c1..e6b6d2f9 100644 --- a/libobjc/archive.c +++ b/libobjc/archive.c @@ -28,10 +28,7 @@ Boston, MA 02111-1307, USA. */ #include "runtime.h" #include "typedstream.h" #include "encoding.h" - -#ifdef HAVE_STDLIB_H #include -#endif extern int fflush(FILE*); @@ -566,7 +563,7 @@ objc_read_short (struct objc_typed_stream* stream, short* value) { 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_typed_stream* stream, { 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* stream, int* value) { 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* stream, long* value) { 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, const char* type, const void* data) 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, const char* type, void* data) 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, const char* type, ...) { 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, const char* type, ...) { 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 --git a/libobjc/class.c b/libobjc/class.c index e6c9437..89ef641 100644 --- a/libobjc/class.c +++ b/libobjc/class.c @@ -163,7 +163,7 @@ static objc_mutex_t __class_table_lock = NULL; /* 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 --git a/libobjc/encoding.c b/libobjc/encoding.c index b30626f..956ca16 100644 --- a/libobjc/encoding.c +++ b/libobjc/encoding.c @@ -87,7 +87,7 @@ atoi (const char* str) { int res = 0; - while (isdigit (*str)) + while (isdigit ((unsigned char)*str)) res *= 10, res += (*str++ - '0'); return res; @@ -180,7 +180,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; @@ -192,7 +192,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; @@ -321,7 +321,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: @@ -487,7 +487,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; @@ -499,8 +499,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: @@ -538,7 +538,7 @@ inline const char* objc_skip_offset (const char* type) { if (*type == '+') type++; - while(isdigit(*++type)); + while(isdigit((unsigned char)*++type)); return type; } @@ -753,8 +753,8 @@ objc_layout_structure_next_member (struct objc_struct_layout *layout) 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 +769,7 @@ objc_layout_structure_next_member (struct objc_struct_layout *layout) 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 +798,7 @@ objc_layout_structure_next_member (struct objc_struct_layout *layout) { 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 --git a/libobjc/gc.c b/libobjc/gc.c index d92c0c3..761905c 100644 --- a/libobjc/gc.c +++ b/libobjc/gc.c @@ -446,13 +446,13 @@ class_ivar_set_gcinvisible (Class class, const char* ivarname, #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 --git a/libobjc/init.c b/libobjc/init.c index 552a74b..e257aee 100644 --- a/libobjc/init.c +++ b/libobjc/init.c @@ -329,7 +329,8 @@ __objc_send_message_in_list (MethodList_t method_list, Class class, SEL op) } 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, int level) } 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(Module_t module) static void __objc_init_protocols (struct objc_protocol_list* protos) { - int i; + size_t i; static Class proto_class = 0; if (! protos) diff --git a/libobjc/nil_method.c b/libobjc/nil_method.c index 1b62128..214235b 100644 --- a/libobjc/nil_method.c +++ b/libobjc/nil_method.c @@ -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 --git a/libobjc/objc/thr.h b/libobjc/objc/thr.h index 59766f6..42403f6 100644 --- a/libobjc/objc/thr.h +++ b/libobjc/objc/thr.h @@ -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 --git a/libobjc/sarray.c b/libobjc/sarray.c index 4625fbe..14135af 100644 --- a/libobjc/sarray.c +++ b/libobjc/sarray.c @@ -211,7 +211,7 @@ sarray_new (int size, void* default_element) 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 newsize) #endif - int counter; + size_t counter; assert(newsize > 0); @@ -382,8 +382,8 @@ sarray_realloc(struct sarray* array, int newsize) /* 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 --git a/libobjc/selector.c b/libobjc/selector.c index 470a2c4..7211f90 100644 --- a/libobjc/selector.c +++ b/libobjc/selector.c @@ -164,8 +164,8 @@ sel_types_match (const char* t1, const char* t2) { 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 --git a/libobjc/sendmsg.c b/libobjc/sendmsg.c index 61fa288..b447884 100644 --- a/libobjc/sendmsg.c +++ b/libobjc/sendmsg.c @@ -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! */ -- cgit v1.1