Hi,

At Tue, 9 Dec 2003 02:43:22 +0900,
Daniel Berger wrote:
> error.c:645: warning: `init_syserr' declared `static' but never defined
> 
> file.c:329: warning: unsigned int format, different type arg (arg 3)
> 
> gc.c:582: warning: unused variable `tmp'
> gc.c:658: warning: unused variable `ret'
> 
> bigdecimal.c:106: warning: int format, different type arg (arg 3)
> 
> curses.c:665: warning: `curses_ungetmouse' defined but not used
> curses.c:1264: warning: `window_bkgdset' defined but not used
> curses.c:1276: warning: `window_bkgd' defined but not used
> curses.c:1289: warning: `window_getbkgd' defined but not used
> 
> dl.c: In function `dlsizeof':
> dl.c:167: warning: subscript has type `char'
> 
> iconv.c: In function `iconv_convert':
> iconv.c:429: warning: int format, different type arg (arg 3)
> iconv.c: In function `Init_iconv':
> iconv.c:839: warning: unused variable `metaclass'
> 
> pty.c: In function `getDevice':
> pty.c:343: warning: unused variable `p'
> pty.c:345: warning: unused variable `MasterName'
> pty.c: At top level:
> pty.c:89: warning: `MasterDevice' defined but not used
> pty.c:90: warning: `SlaveDevice' defined but not used
> pty.c:91: warning: `deviceNo' defined but not used
> pty.c:404: warning: `freeDevice' defined but not used
> 
> socket.c: In function `port_str':
> socket.c:599: warning: int format, different type arg (arg 4)
> socket.c: In function `sock_s_getaddrinfo':
> socket.c:2109: warning: int format, different type arg (arg 4)
> socket.c: In function `sock_s_getnameinfo':
> socket.c:2228: warning: int format, different type arg (arg 4)
> 
> rubyext.c: In function `rb_syck_compile':
> rubyext.c:96: warning: implicit declaration of function `syck_parser_assign_io'

Does following patch clean these warnings?

> eval.c:9032: warning: `limit' might be used uninitialized in this function
> 
> process.c: In function `rb_syswait':
> process.c:909: warning: `hfunc' might be used uninitialized in this function
> process.c:909: warning: `qfunc' might be used uninitialized in this function
> process.c:909: warning: `ifunc' might be used uninitialized in this function
> 
> socket.c: In function `ipaddr':
> socket.c:660: warning: `addr1' might be used uninitialized in this function
> socket.c: In function `init_inetsock_internal':
> socket.c:897: warning: `syscall' might be used uninitialized in this function

These are used conditionally.  As for the last one, I guess
`status' should be warned rather than it.

> sym.c:365: warning: unused variable `guard'

I think this must be a "volatile pointer" instead of a "pointer
to volatile".

> numeric.c:791: warning: implicit declaration of function `finite'

Does math.h on Solaris lack finite()?

> parse.y:4443: warning: `nodeline' defined but not used

This and nodetype() are for debug use.

> socket.c: In function `bsock_getsockopt':
> socket.c:317: warning: implicit declaration of function `alloca'

ALLOCA_N() macro is used in many place, why is it warned only
here?

> bigdecimal.c:1582: warning: `VpIsNegDoubleZero' defined but not used
> bigdecimal.c:3573: warning: `VpItoV' defined but not used

I'm not sure whether these are planned to use or not.

> rubyext.c: In function `syck_set_model':
> rubyext.c:681: warning: implicit declaration of function `syck_parser_set_input_type'

I suspect this should be declared in syck.h, but not sure.
Since other syck stuff are tool-generated, only _why can fix
them.


Index: error.c =================================================================== RCS file: /cvs/ruby/src/ruby/error.c,v retrieving revision 1.83 diff -u -2 -p -d -r1.83 error.c --- error.c 22 Nov 2003 03:59:17 -0000 1.83 +++ error.c 9 Dec 2003 00:11:51 -0000 @@ -642,6 +642,4 @@ syserr_eqq(self, exc) return Qfalse; } - -static void init_syserr _((void)); void Index: file.c =================================================================== RCS file: /cvs/ruby/src/ruby/file.c,v retrieving revision 1.164 diff -u -2 -p -d -r1.164 file.c --- file.c 28 Nov 2003 14:23:31 -0000 1.164 +++ file.c 9 Dec 2003 00:17:13 -0000 @@ -327,5 +327,5 @@ rb_stat_inspect(self) char buf[32]; - sprintf(buf, "0%o", NUM2INT(v)); + sprintf(buf, "0%o", NUM2UINT(v)); rb_str_buf_cat2(str, buf); } Index: gc.c =================================================================== RCS file: /cvs/ruby/src/ruby/gc.c,v retrieving revision 1.164 diff -u -2 -p -d -r1.164 gc.c --- gc.c 28 Nov 2003 14:23:31 -0000 1.164 +++ gc.c 9 Dec 2003 00:17:31 -0000 @@ -580,5 +580,4 @@ rb_gc_mark_locations(start, end) VALUE *start, *end; { - VALUE *tmp; long n; @@ -656,5 +655,4 @@ gc_mark(ptr, lev) int lev; { - int ret; register RVALUE *obj; Index: parse.y =================================================================== RCS file: /cvs/ruby/src/ruby/parse.y,v retrieving revision 1.305 diff -u -2 -p -d -r1.305 parse.y --- parse.y 4 Dec 2003 07:41:20 -0000 1.305 +++ parse.y 9 Dec 2003 00:22:12 -0000 @@ -5444,5 +5444,5 @@ arg_prepend(node1, node2) NODE *node1, *node2; { - switch (nodetype(node2)) { + switch (nd_type(node2)) { case NODE_ARRAY: return list_concat(NEW_LIST(node1), node2); @@ -5456,5 +5456,5 @@ arg_prepend(node1, node2) default: - rb_bug("unknown nodetype(%d) for arg_prepend", nodetype(node2)); + rb_bug("unknown nodetype(%d) for arg_prepend", nd_type(node2)); } return 0; /* not reached */ Index: ext/bigdecimal/bigdecimal.c =================================================================== RCS file: /cvs/ruby/src/ruby/ext/bigdecimal/bigdecimal.c,v retrieving revision 1.38 diff -u -2 -p -d -r1.38 bigdecimal.c --- ext/bigdecimal/bigdecimal.c 21 Oct 2003 03:29:54 -0000 1.38 +++ ext/bigdecimal/bigdecimal.c 9 Dec 2003 00:23:45 -0000 @@ -104,5 +104,5 @@ GetVpValue(VALUE v, int must) break; case T_FIXNUM: - sprintf(szD, "%d", FIX2INT(v)); + sprintf(szD, "%ld", FIX2INT(v)); return VpCreateRbObject(VpBaseFig() * 2 + 1, szD); @@ -147,7 +147,6 @@ BigDecimal_prec(VALUE self) GUARD_OBJ(p,GetVpValue(self,1)); - obj = rb_ary_new(); - obj = rb_ary_push(obj,INT2NUM(p->Prec*VpBaseFig())); - obj = rb_ary_push(obj,INT2NUM(p->MaxPrec*VpBaseFig())); + obj = rb_assoc_new(INT2NUM(p->Prec*VpBaseFig()), + INT2NUM(p->MaxPrec*VpBaseFig())); return obj; } @@ -428,12 +427,8 @@ BigDecimal_coerce(VALUE self, VALUE othe Real *b; if(TYPE(other) == T_FLOAT) { - obj = rb_ary_new(); - obj = rb_ary_push(obj,other); - obj = rb_ary_push(obj,BigDecimal_to_f(self)); + obj = rb_assoc_new(other, BigDecimal_to_f(self)); } else { GUARD_OBJ(b,GetVpValue(other,1)); - obj = rb_ary_new(); - obj = rb_ary_push(obj, b->obj); - obj = rb_ary_push(obj, self); + obj = rb_assoc_new(b->obj, self); } return obj; @@ -781,7 +776,5 @@ BigDecimal_divmod(VALUE self, VALUE r) if(obj!=(VALUE)0) return obj; SAVE(div);SAVE(mod); - obj = rb_ary_new(); - rb_ary_push(obj, ToValue(div)); - rb_ary_push(obj, ToValue(mod)); + obj = rb_assoc_new(ToValue(div), ToValue(mod)); return obj; } @@ -1125,5 +1118,5 @@ BigDecimal_split(VALUE self) e = VpExponent10(vp); obj1 = rb_str_new2(psz1); - obj = rb_ary_new(); + obj = rb_ary_new2(4); rb_ary_push(obj, INT2FIX(s)); rb_ary_push(obj, obj1); Index: ext/curses/curses.c =================================================================== RCS file: /cvs/ruby/src/ruby/ext/curses/curses.c,v retrieving revision 1.23 diff -u -2 -p -d -r1.23 curses.c --- ext/curses/curses.c 22 Nov 2003 09:51:07 -0000 1.23 +++ ext/curses/curses.c 9 Dec 2003 00:27:14 -0000 @@ -1260,4 +1260,5 @@ window_attrset(VALUE obj, VALUE attrs) } +#ifdef USE_COLOR static VALUE window_bkgdset(VALUE obj, VALUE ch) @@ -1298,4 +1299,5 @@ window_getbkgd(VALUE obj) #endif } +#endif /* USE_COLOR */ static VALUE @@ -1444,5 +1446,5 @@ Init_curses() #ifdef USE_MOUSE rb_define_module_function(mCurses, "getmouse", curses_getmouse, 0); - rb_define_module_function(mCurses, "ungetmouse", curses_getmouse, 1); + rb_define_module_function(mCurses, "ungetmouse", curses_ungetmouse, 1); rb_define_module_function(mCurses, "mouseinterval", curses_mouseinterval, 1); rb_define_module_function(mCurses, "mousemask", curses_mousemask, 1); Index: ext/dl/sym.c =================================================================== RCS file: /cvs/ruby/src/ruby/ext/dl/sym.c,v retrieving revision 1.23 diff -u -2 -p -d -r1.23 sym.c --- ext/dl/sym.c 4 Dec 2003 01:45:07 -0000 1.23 +++ ext/dl/sym.c 9 Dec 2003 00:46:01 -0000 @@ -363,5 +363,5 @@ static int rb_dlsym_guardcall(char type, ANY_TYPE *ret, long *stack, void *func) { - volatile char *guard = ALLOCA_N(char, 1); /* guard stack pointer */ + char *volatile guard = ALLOCA_N(char, 1); /* guard stack pointer */ switch(type){ case '0': Index: ext/iconv/charset_alias.rb =================================================================== RCS file: /cvs/ruby/src/ruby/ext/iconv/charset_alias.rb,v retrieving revision 1.4 diff -u -2 -p -d -r1.4 charset_alias.rb --- ext/iconv/charset_alias.rb 7 Dec 2003 11:55:11 -0000 1.4 +++ ext/iconv/charset_alias.rb 7 Dec 2003 13:02:10 -0000 @@ -8,6 +8,19 @@ OS = Config::CONFIG["target"] SHELL = Config::CONFIG['SHELL'] +class Hash::Ordered < Hash + def [](key) + val = super and val.last + end + def []=(key, val) + ary = fetch(key) {return super(key, [self.size, key, val])} and + ary.last = val + end + def each + values.sort.each {|i, key, val| yield key, val} + end +end + def charset_alias(config_charset, mapfile, target = OS) - map = {} + map = Hash::Ordered.new comments = [] IO.foreach("|#{SHELL} #{config_charset} #{target}") do |list| @@ -30,5 +43,5 @@ def charset_alias(config_charset, mapfil f.puts(comments) f.puts("class Iconv") - map.keys.sort.each {|can| f.puts(" charset_map['#{can}'.freeze] = '#{map[can]}'.freeze")} + map.each {|can, sys| f.puts(" charset_map['#{can}'.freeze] = '#{sys}'.freeze")} f.puts("end") end Index: ext/iconv/iconv.c =================================================================== RCS file: /cvs/ruby/src/ruby/ext/iconv/iconv.c,v retrieving revision 1.13 diff -u -2 -p -d -r1.13 iconv.c --- ext/iconv/iconv.c 7 Dec 2003 11:39:29 -0000 1.13 +++ ext/iconv/iconv.c 9 Dec 2003 00:48:28 -0000 @@ -427,5 +427,5 @@ iconv_convert else { /* Some iconv() have a bug, return *outlen out of range */ - sprintf(errmsg, "bug?(output length = %d)", sizeof(buffer) - outlen); + sprintf(errmsg, "bug?(output length = %ld)", (long)(sizeof(buffer) - outlen)); error = rb_eIconvOutOfRange; } @@ -837,5 +837,4 @@ Init_iconv _((void)) { VALUE rb_cIconv = rb_define_class("Iconv", rb_cData); - VALUE metaclass = RBASIC(rb_cIconv)->klass; rb_define_alloc_func(rb_cIconv, iconv_s_allocate); Index: ext/pty/pty.c =================================================================== RCS file: /cvs/ruby/src/ruby/ext/pty/pty.c,v retrieving revision 1.17 diff -u -2 -p -d -r1.17 pty.c --- ext/pty/pty.c 22 Nov 2003 03:59:29 -0000 1.17 +++ ext/pty/pty.c 9 Dec 2003 00:50:07 -0000 @@ -341,7 +341,5 @@ getDevice(master,slave) int *master,*slave; { - char **p; int i,j; - char MasterName[DEVICELEN]; #ifdef HAVE_PTSNAME @@ -380,4 +378,7 @@ getDevice(master,slave) rb_raise(rb_eRuntimeError, "Cannot get Master/Slave device"); #else + char **p; + char MasterName[DEVICELEN]; + for (p = deviceNo; *p != NULL; p++) { sprintf(MasterName,MasterDevice,*p); Index: ext/socket/socket.c =================================================================== RCS file: /cvs/ruby/src/ruby/ext/socket/socket.c,v retrieving revision 1.106 diff -u -2 -p -d -r1.106 socket.c --- ext/socket/socket.c 22 Nov 2003 03:59:33 -0000 1.106 +++ ext/socket/socket.c 9 Dec 2003 00:59:06 -0000 @@ -597,5 +597,5 @@ port_str(port, pbuf, len) } else if (FIXNUM_P(port)) { - snprintf(pbuf, len, "%d", FIX2INT(port)); + snprintf(pbuf, len, "%ld", FIX2INT(port)); return pbuf; } @@ -894,5 +894,5 @@ init_inetsock_internal(arg) int type = arg->type; struct addrinfo *res; - int fd, status; + int fd, status = 0; char *syscall; @@ -2107,5 +2107,5 @@ sock_s_getaddrinfo(argc, argv) } else if (FIXNUM_P(port)) { - snprintf(pbuf, sizeof(pbuf), "%d", FIX2INT(port)); + snprintf(pbuf, sizeof(pbuf), "%ld", FIX2INT(port)); pptr = pbuf; } @@ -2226,5 +2226,5 @@ sock_s_getnameinfo(argc, argv) } else if (FIXNUM_P(port)) { - snprintf(pbuf, sizeof(pbuf), "%d", NUM2INT(port)); + snprintf(pbuf, sizeof(pbuf), "%ld", NUM2INT(port)); pptr = pbuf; } Index: ext/syck/rubyext.c =================================================================== RCS file: /cvs/ruby/src/ruby/ext/syck/rubyext.c,v retrieving revision 1.28 diff -u -2 -p -d -r1.28 rubyext.c --- ext/syck/rubyext.c 25 Nov 2003 19:51:38 -0000 1.28 +++ ext/syck/rubyext.c 9 Dec 2003 01:01:22 -0000 @@ -73,4 +73,5 @@ void rb_syck_err_handler _((SyckParser * SyckNode * rb_syck_bad_anchor_handler _((SyckParser *, char *)); void rb_syck_output_handler _((SyckEmitter *, char *, long)); +int syck_parser_assign_io _((SyckParser *, VALUE)); struct parser_xtra {
-- Nobu Nakada