[Patch] Wall compilation
From:
Michal Rokos <michal@...>
Date:
2003-01-15 21:35:45 UTC
List:
ruby-core #686
Hi everybody, I changed my email.... and been quiet for a very long time... This patch makes -Wall compilation more quiet... If you read the patch, please note change in defines.h FLUSH_REGISTER_WINDOWS is now defined everytime, but compilation with -O2 handles empty proc body quite well (ie. no code - no useless jumps). Michal
Attachments (1)
RubyWallClean1.diff
(18.2 KB, text/x-diff)
Index: bignum.c
===================================================================
RCS file: /src/ruby/bignum.c,v
retrieving revision 1.82
diff -u -p -r1.82 bignum.c
--- bignum.c 14 Jan 2003 07:45:18 -0000 1.82
+++ bignum.c 15 Jan 2003 20:52:40 -0000
@@ -392,10 +392,8 @@ rb_cstr_to_inum(str, base, badcheck)
}
break;
}
- if (*str == '0') { /* squeeze preceeding 0s */
- while (*++str == '0');
- --str;
- }
+ while (*str == '0') str++; /* squeeze preceeding 0s */
+
len *= strlen(str)*sizeof(char);
if (len <= (sizeof(VALUE)*CHAR_BIT)) {
@@ -1125,7 +1123,7 @@ bigdivrem(x, y, divp, modp)
yds = BDIGITS(y);
if (ny == 0 && yds[0] == 0) rb_num_zerodiv();
- if (nx < ny || nx == ny && BDIGITS(x)[nx - 1] < BDIGITS(y)[ny - 1]) {
+ if (nx < ny || (nx == ny && BDIGITS(x)[nx - 1] < BDIGITS(y)[ny - 1])) {
if (divp) *divp = rb_int2big(0);
if (modp) *modp = x;
return;
Index: defines.h
===================================================================
RCS file: /src/ruby/defines.h,v
retrieving revision 1.25
diff -u -p -r1.25 defines.h
--- defines.h 4 Jan 2003 18:57:37 -0000 1.25
+++ defines.h 15 Jan 2003 20:52:41 -0000
@@ -137,10 +137,10 @@ void xfree _((void*));
#define EXTERN extern
#endif
-#if defined(sparc) || defined(__sparc__)
static inline void
flush_register_windows(void)
{
+#if defined(sparc) || defined(__sparc__)
# if defined(__sparc_v9__) || defined(__arch64__)
asm volatile ("flushw" : :);
# elif defined(linux) || defined(__linux__)
@@ -148,11 +148,9 @@ flush_register_windows(void)
# else /* Solaris, OpenBSD, NetBSD, etc. */
asm volatile ("ta 0x03");
# endif /* trap always to flush register windows if we are on a Sparc system */
+#endif
}
#define FLUSH_REGISTER_WINDOWS flush_register_windows()
-#else /* Not a sparc, so */
-#define FLUSH_REGISTER_WINDOWS NULL
-#endif
#if defined(DOSISH)
#define PATH_SEP ";"
Index: dln.c
===================================================================
RCS file: /src/ruby/dln.c,v
retrieving revision 1.48
diff -u -p -r1.48 dln.c
--- dln.c 31 Dec 2002 10:53:14 -0000 1.48
+++ dln.c 15 Jan 2003 20:52:42 -0000
@@ -1304,7 +1304,7 @@ dln_load(file)
char *buf;
/* Load the file as an object one */
- init_funcname(&buf, file);
+ init_funcname(&buf, (char *)file);
#ifdef USE_DLN_DLOPEN
#define DLN_DEFINED
Index: enum.c
===================================================================
RCS file: /src/ruby/enum.c,v
retrieving revision 1.33
diff -u -p -r1.33 enum.c
--- enum.c 15 Jan 2003 08:07:41 -0000 1.33
+++ enum.c 15 Jan 2003 20:52:43 -0000
@@ -541,11 +541,10 @@ enum_zip(argc, argv, obj)
VALUE *argv;
VALUE obj;
{
- int i, j, len;
+ int i;
VALUE result;
NODE *memo;
- len = 0;
for (i=0; i<argc; i++) {
argv[i] = rb_convert_type(argv[i], T_ARRAY, "Array", "to_ary");
}
Index: eval.c
===================================================================
RCS file: /src/ruby/eval.c,v
retrieving revision 1.384
diff -u -p -r1.384 eval.c
--- eval.c 15 Jan 2003 08:07:41 -0000 1.384
+++ eval.c 15 Jan 2003 20:52:50 -0000
@@ -938,7 +938,7 @@ static void call_trace_func _((char*,NOD
#define SET_CURRENT_SOURCE() (ruby_sourcefile = ruby_current_node->nd_file, \
ruby_sourceline = nd_line(ruby_current_node))
#else
-#define SET_CURRENT_SOURCE() 0
+#define SET_CURRENT_SOURCE() do { } while (0)
#endif
void
@@ -2050,14 +2050,14 @@ is_defined(self, node, buf)
case NODE_NTH_REF:
if (RTEST(rb_reg_nth_defined(node->nd_nth, MATCH_DATA))) {
- sprintf(buf, "$%d", node->nd_nth);
+ sprintf(buf, "$%d", (int)node->nd_nth);
return buf;
}
break;
case NODE_BACK_REF:
if (RTEST(rb_reg_nth_defined(0, MATCH_DATA))) {
- sprintf(buf, "$%c", node->nd_nth);
+ sprintf(buf, "$%c", (char)node->nd_nth);
return buf;
}
break;
@@ -2181,6 +2181,8 @@ call_trace_func(event, node, self, id, k
if (state) JUMP_TAG(state);
}
+VALUE rb_check_array_type _((VALUE));
+
static VALUE
avalue_to_svalue(v)
VALUE v;
@@ -3533,7 +3535,6 @@ static VALUE
rb_mod_public_method_defined(mod, mid)
VALUE mod, mid;
{
- VALUE klass;
ID id = rb_to_id(mid);
int noex;
@@ -3548,7 +3549,6 @@ static VALUE
rb_mod_private_method_defined(mod, mid)
VALUE mod, mid;
{
- VALUE klass;
ID id = rb_to_id(mid);
int noex;
@@ -3563,7 +3563,6 @@ static VALUE
rb_mod_protected_method_defined(mod, mid)
VALUE mod, mid;
{
- VALUE klass;
ID id = rb_to_id(mid);
int noex;
@@ -4444,7 +4443,7 @@ rb_undefined(obj, id, argc, argv, call_s
VALUE obj;
ID id;
int argc;
- VALUE*argv;
+ const VALUE *argv;
int call_status;
{
VALUE *nargv;
@@ -7005,7 +7004,7 @@ method_call(argc, argv, method)
VALUE *argv;
VALUE method;
{
- VALUE result;
+ VALUE result; /* OK */
struct METHOD *data;
int state;
volatile int safe = ruby_safe_level;
Index: gc.c
===================================================================
RCS file: /src/ruby/gc.c,v
retrieving revision 1.118
diff -u -p -r1.118 gc.c
--- gc.c 6 Jan 2003 16:37:29 -0000 1.118
+++ gc.c 15 Jan 2003 20:52:51 -0000
@@ -879,7 +879,7 @@ gc_sweep()
RVALUE *p, *pend, *final_list;
int freed = 0;
int i, j;
- unsigned long live = 0, garbage = 0;
+ unsigned long live = 0;
if (ruby_in_compile && ruby_parser_stack_on_heap()) {
/* should not reclaim nodes during compilation
Index: hash.c
===================================================================
RCS file: /src/ruby/hash.c,v
retrieving revision 1.90
diff -u -p -r1.90 hash.c
--- hash.c 7 Jan 2003 07:36:35 -0000 1.90
+++ hash.c 15 Jan 2003 20:52:51 -0000
@@ -1076,7 +1076,7 @@ rb_env_path_tainted()
static int
envix(nam)
-const char *nam;
+ const char *nam;
{
register int i, len = strlen(nam);
char **env;
Index: io.c
===================================================================
RCS file: /src/ruby/io.c,v
retrieving revision 1.181
diff -u -p -r1.181 io.c
--- io.c 13 Jan 2003 16:24:40 -0000 1.181
+++ io.c 15 Jan 2003 20:52:53 -0000
@@ -2583,6 +2583,8 @@ io_puts_ary(ary, out)
}
return Qnil;
}
+
+VALUE rb_check_array_type _((VALUE));
VALUE
rb_io_puts(argc, argv, out)
Index: parse.y
===================================================================
RCS file: /src/ruby/parse.y,v
retrieving revision 1.245
diff -u -p -r1.245 parse.y
--- parse.y 14 Jan 2003 07:45:19 -0000 1.245
+++ parse.y 15 Jan 2003 20:52:59 -0000
@@ -391,7 +391,7 @@ stmt : kALIAS fitem {lex_state = EXPR_F
{
char buf[3];
- sprintf(buf, "$%c", $3->nd_nth);
+ sprintf(buf, "$%c", (char)$3->nd_nth);
$$ = NEW_VALIAS($2, rb_intern(buf));
}
| kALIAS tGVAR tNTH_REF
@@ -3134,7 +3134,7 @@ whole_match_p(eos, len, indent)
while (*p && ISSPACE(*p)) p++;
}
n= lex_pend - (p + len);
- if (n < 0 || n > 0 && p[len] != '\n' && p[len] != '\r') return Qfalse;
+ if (n < 0 || (n > 0 && p[len] != '\n' && p[len] != '\r')) return Qfalse;
if (strncmp(eos, p, len) == 0) return Qtrue;
return Qfalse;
}
Index: range.c
===================================================================
RCS file: /src/ruby/range.c,v
retrieving revision 1.49
diff -u -p -r1.49 range.c
--- range.c 8 Jan 2003 06:05:08 -0000 1.49
+++ range.c 15 Jan 2003 20:53:00 -0000
@@ -285,12 +285,12 @@ range_step(argc, argv, range)
return range;
}
-static void
+static VALUE
each_i(v, arg)
VALUE v;
void *arg;
{
- rb_yield(v);
+ return rb_yield(v);
}
static VALUE
@@ -324,7 +324,7 @@ range_each(range)
rb_iterate((VALUE(*)_((VALUE)))str_step, (VALUE)args, step_i, (VALUE)iter);
}
else {
- range_each_func(range, each_i, beg, end, 0);
+ range_each_func(range, each_i, beg, end, NULL);
}
return range;
}
Index: ruby.c
===================================================================
RCS file: /src/ruby/ruby.c,v
retrieving revision 1.71
diff -u -p -r1.71 ruby.c
--- ruby.c 5 Jan 2003 01:40:23 -0000 1.71
+++ ruby.c 15 Jan 2003 20:53:01 -0000
@@ -618,7 +618,7 @@ proc_options(argc, argv)
goto reswitch;
case '-':
- if (!s[1] || s[1] == '\r' && !s[2]) {
+ if (!s[1] || (s[1] == '\r' && !s[2])) {
argc--,argv++;
goto switch_end;
}
Index: ext/dbm/dbm.c
===================================================================
RCS file: /src/ruby/ext/dbm/dbm.c,v
retrieving revision 1.21
diff -u -p -r1.21 dbm.c
--- ext/dbm/dbm.c 21 Dec 2002 19:08:50 -0000 1.21
+++ ext/dbm/dbm.c 15 Jan 2003 20:53:07 -0000
@@ -237,7 +237,6 @@ fdbm_select(argc, argv, obj)
datum key, val;
DBM *dbm;
struct dbmdata *dbmp;
- VALUE keystr, valstr;
if (argc > 0) {
rb_raise(rb_eArgError, "wrong number arguments(%d for 0)", argc);
Index: ext/dl/dl.c
===================================================================
RCS file: /src/ruby/ext/dl/dl.c,v
retrieving revision 1.15
diff -u -p -r1.15 dl.c
--- ext/dl/dl.c 26 Nov 2002 10:53:11 -0000 1.15
+++ ext/dl/dl.c 15 Jan 2003 20:53:07 -0000
@@ -554,8 +554,6 @@ rb_dl_malloc(VALUE self, VALUE size)
VALUE
rb_dl_strdup(VALUE self, VALUE str)
{
- void *p;
-
str = rb_String(str);
return rb_dlptr_new(strdup(RSTRING(str)->ptr), RSTRING(str)->len, dlfree);
}
Index: ext/dl/handle.c
===================================================================
RCS file: /src/ruby/ext/dl/handle.c,v
retrieving revision 1.7
diff -u -p -r1.7 handle.c
--- ext/dl/handle.c 12 Jan 2003 13:11:32 -0000 1.7
+++ ext/dl/handle.c 15 Jan 2003 20:53:07 -0000
@@ -133,9 +133,6 @@ rb_dlhandle_sym(int argc, VALUE argv[],
VALUE sym, type;
void (*func)();
VALUE val;
- struct sym_data *data;
- int *ctypes;
- int i, ctypes_len;
struct dl_handle *dlhandle;
void *handle;
const char *name, *stype;
Index: ext/dl/ptr.c
===================================================================
RCS file: /src/ruby/ext/dl/ptr.c,v
retrieving revision 1.15
diff -u -p -r1.15 ptr.c
--- ext/dl/ptr.c 6 Jan 2003 11:47:53 -0000 1.15
+++ ext/dl/ptr.c 15 Jan 2003 20:53:08 -0000
@@ -178,7 +178,7 @@ rb_dlptr_s_allocate(VALUE klass)
static VALUE
rb_dlptr_initialize(int argc, VALUE argv[], VALUE self)
{
- VALUE ptr, sym, obj, size;
+ VALUE ptr, sym, size;
struct ptr_data *data;
void *p = NULL;
freefunc_t f = NULL;
@@ -279,7 +279,6 @@ VALUE
rb_dlptr_free_set(VALUE self, VALUE val)
{
struct ptr_data *data;
- int i;
Data_Get_Struct(self, struct ptr_data, data);
@@ -463,10 +462,9 @@ rb_dlptr_inspect(VALUE self)
{
struct ptr_data *data;
char str[1024];
- VALUE name;
Data_Get_Struct(self, struct ptr_data, data);
- snprintf(str, 1023, "#<%s:0x%x ptr=0x%x size=%ld free=0x%x>",
+ snprintf(str, 1023, "#<%s:0x%p ptr=0x%p size=%ld free=0x%p>",
rb_class2name(CLASS_OF(self)), data, data->ptr, data->size, data->free);
return rb_str_new2(str);
}
@@ -519,9 +517,8 @@ rb_dlptr_define_data_type(int argc, VALU
{
VALUE data_type, type, rest, vid;
struct ptr_data *data;
- int i, t, len, num;
+ int i, t, num;
char *ctype;
- long size;
rb_scan_args(argc, argv, "11*", &data_type, &type, &rest);
Data_Get_Struct(self, struct ptr_data, data);
@@ -731,9 +728,8 @@ cary2ary(void *ptr, char t, int len)
VALUE
rb_dlptr_aref(int argc, VALUE argv[], VALUE self)
{
- VALUE val, key = Qnil, num = Qnil;
+ VALUE key = Qnil, num = Qnil;
ID id;
- int idx;
struct ptr_data *data;
int i;
int offset;
Index: ext/dl/sym.c
===================================================================
RCS file: /src/ruby/ext/dl/sym.c,v
retrieving revision 1.15
diff -u -p -r1.15 sym.c
--- ext/dl/sym.c 20 Dec 2002 11:23:39 -0000 1.15
+++ ext/dl/sym.c 15 Jan 2003 20:53:08 -0000
@@ -145,7 +145,6 @@ VALUE
rb_dlsym_initialize(int argc, VALUE argv[], VALUE self)
{
VALUE addr, name, type;
- VALUE val;
struct sym_data *data;
void *saddr;
const char *sname, *stype;
@@ -266,7 +265,7 @@ rb_dlsym_inspect(VALUE self)
str_size = RSTRING(proto)->len + 100;
str = dlmalloc(str_size);
snprintf(str, str_size - 1,
- "#<DL::Symbol:0x%x func=0x%x '%s'>",
+ "#<DL::Symbol:0x%p func=0x%p '%s'>",
sym, sym->func, RSTRING(proto)->ptr);
val = rb_tainted_str_new2(str);
dlfree(str);
Index: ext/etc/etc.c
===================================================================
RCS file: /src/ruby/ext/etc/etc.c,v
retrieving revision 1.7
diff -u -p -r1.7 etc.c
--- ext/etc/etc.c 8 Sep 2002 10:00:43 -0000 1.7
+++ ext/etc/etc.c 15 Jan 2003 20:53:08 -0000
@@ -93,7 +93,7 @@ etc_getpwuid(argc, argv, obj)
VALUE obj;
{
#if defined(HAVE_GETPWENT)
- VALUE id, ary;
+ VALUE id;
int uid;
struct passwd *pwd;
Index: ext/readline/readline.c
===================================================================
RCS file: /src/ruby/ext/readline/readline.c,v
retrieving revision 1.11
diff -u -p -r1.11 readline.c
--- ext/readline/readline.c 30 Aug 2002 10:41:57 -0000 1.11
+++ ext/readline/readline.c 15 Jan 2003 20:53:08 -0000
@@ -3,6 +3,7 @@
#include <errno.h>
#include <stdio.h>
+#include <unistd.h>
#include <readline/readline.h>
#include <readline/history.h>
@@ -228,7 +229,6 @@ readline_s_set_basic_word_break_characte
{
#ifdef READLINE_21_OR_LATER
static char *basic_word_break_characters = NULL;
- char *s;
StringValue(str);
if (basic_word_break_characters == NULL) {
@@ -268,7 +268,6 @@ readline_s_set_completer_word_break_char
{
#ifdef READLINE_21_OR_LATER
static char *completer_word_break_characters = NULL;
- char *s;
StringValue(str);
if (completer_word_break_characters == NULL) {
@@ -308,7 +307,6 @@ readline_s_set_basic_quote_characters(se
{
#ifdef READLINE_21_OR_LATER
static char *basic_quote_characters = NULL;
- char *s;
StringValue(str);
if (basic_quote_characters == NULL) {
@@ -348,7 +346,6 @@ readline_s_set_completer_quote_character
{
#ifdef READLINE_21_OR_LATER
static char *completer_quote_characters = NULL;
- char *s;
StringValue(str);
if (completer_quote_characters == NULL) {
@@ -388,7 +385,6 @@ readline_s_set_filename_quote_characters
{
#ifdef READLINE_21_OR_LATER
static char *filename_quote_characters = NULL;
- char *s;
StringValue(str);
if (filename_quote_characters == NULL) {
Index: ext/sdbm/init.c
===================================================================
RCS file: /src/ruby/ext/sdbm/init.c,v
retrieving revision 1.16
diff -u -p -r1.16 init.c
--- ext/sdbm/init.c 21 Dec 2002 18:02:01 -0000 1.16
+++ ext/sdbm/init.c 15 Jan 2003 20:53:09 -0000
@@ -225,7 +225,6 @@ fsdbm_select(argc, argv, obj)
datum key, val;
DBM *dbm;
struct dbmdata *dbmp;
- VALUE keystr, valstr;
if (argc > 0) {
rb_raise(rb_eArgError, "wrong number arguments(%d for 0)", argc);
Index: ext/socket/socket.c
===================================================================
RCS file: /src/ruby/ext/socket/socket.c,v
retrieving revision 1.90
diff -u -p -r1.90 socket.c
--- ext/socket/socket.c 29 Dec 2002 20:14:51 -0000 1.90
+++ ext/socket/socket.c 15 Jan 2003 20:53:12 -0000
@@ -879,7 +879,7 @@ init_inetsock_internal(arg)
struct inetsock_arg *arg;
{
int type = arg->type;
- struct addrinfo hints, *res;
+ struct addrinfo *res;
int fd, status;
char *syscall;
@@ -972,12 +972,11 @@ tcp_init(argc, argv, sock)
VALUE remote_host, remote_serv;
VALUE local_host, local_serv;
- int pcount = rb_scan_args(argc, argv, "22",
- &remote_host, &remote_serv,
- &local_host, &local_serv);
+ rb_scan_args(argc, argv, "22", &remote_host, &remote_serv,
+ &local_host, &local_serv);
return init_inetsock(sock, remote_host, remote_serv,
- local_host, local_serv, INET_CLIENT);
+ local_host, local_serv, INET_CLIENT);
}
#ifdef SOCKS
@@ -1362,7 +1361,6 @@ udp_connect(sock, host, port)
VALUE sock, host, port;
{
OpenFile *fptr;
- int fd;
struct udp_arg arg;
VALUE ret;
@@ -2185,7 +2183,7 @@ sock_s_getnameinfo(argc, argv)
int error;
struct sockaddr_storage ss;
struct sockaddr *sap;
- char *ep, *ap;
+ char *ap;
sa = flags = Qnil;
rb_scan_args(argc, argv, "11", &sa, &flags);
Index: ext/stringio/stringio.c
===================================================================
RCS file: /src/ruby/ext/stringio/stringio.c,v
retrieving revision 1.12
diff -u -p -r1.12 stringio.c
--- ext/stringio/stringio.c 20 Dec 2002 11:23:40 -0000 1.12
+++ ext/stringio/stringio.c 15 Jan 2003 20:53:12 -0000
@@ -148,7 +148,7 @@ static VALUE strio_closed _((VALUE));
static VALUE strio_closed_read _((VALUE));
static VALUE strio_closed_write _((VALUE));
static VALUE strio_eof _((VALUE));
-static VALUE strio_become _((VALUE, VALUE));
+/* static VALUE strio_become _((VALUE, VALUE)); NOT USED */
static VALUE strio_get_lineno _((VALUE));
static VALUE strio_set_lineno _((VALUE, VALUE));
static VALUE strio_get_pos _((VALUE));
@@ -156,7 +156,7 @@ static VALUE strio_set_pos _((VALUE, VAL
static VALUE strio_rewind _((VALUE));
static VALUE strio_seek _((int, VALUE *, VALUE));
static VALUE strio_get_sync _((VALUE));
-static VALUE strio_set_sync _((VALUE, VALUE));
+/* static VALUE strio_set_sync _((VALUE, VALUE)); NOT USED */
static VALUE strio_each_byte _((VALUE));
static VALUE strio_getc _((VALUE));
static VALUE strio_ungetc _((VALUE, VALUE));
@@ -167,8 +167,8 @@ static VALUE strio_readline _((int, VALU
static VALUE strio_each _((int, VALUE *, VALUE));
static VALUE strio_readlines _((int, VALUE *, VALUE));
static VALUE strio_write _((VALUE, VALUE));
-static VALUE strio_print _((int, VALUE *, VALUE));
-static VALUE strio_printf _((int, VALUE *, VALUE));
+/* static VALUE strio_print _((int, VALUE *, VALUE)); NOT USED */
+/* static VALUE strio_printf _((int, VALUE *, VALUE)); NOT USED */
static VALUE strio_putc _((VALUE, VALUE));
static VALUE strio_read _((int, VALUE *, VALUE));
static VALUE strio_size _((VALUE));
Index: ext/syslog/syslog.c
===================================================================
RCS file: /src/ruby/ext/syslog/syslog.c,v
retrieving revision 1.6
diff -u -p -r1.6 syslog.c
--- ext/syslog/syslog.c 27 Nov 2002 08:40:40 -0000 1.6
+++ ext/syslog/syslog.c 15 Jan 2003 20:53:12 -0000
@@ -54,7 +54,6 @@ static VALUE mSyslog_close(VALUE self)
static VALUE mSyslog_open(int argc, VALUE *argv, VALUE self)
{
VALUE ident, opt, fac;
- int mask;
if (syslog_opened) {
rb_raise(rb_eRuntimeError, "syslog already open");