-Wall cleanups (removed unused vars, no 'code has no effect' warnings)

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3346 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
michal 2003-01-16 07:38:40 +00:00
parent 9df466b287
commit 4e13d36561
20 changed files with 35 additions and 62 deletions

View File

@ -392,10 +392,8 @@ rb_cstr_to_inum(str, base, badcheck)
} }
break; break;
} }
if (*str == '0') { /* squeeze preceeding 0s */ while (*str == '0') str++; /* squeeze preceeding 0s */
while (*++str == '0');
--str;
}
len *= strlen(str)*sizeof(char); len *= strlen(str)*sizeof(char);
if (len <= (sizeof(VALUE)*CHAR_BIT)) { if (len <= (sizeof(VALUE)*CHAR_BIT)) {
@ -1125,7 +1123,7 @@ bigdivrem(x, y, divp, modp)
yds = BDIGITS(y); yds = BDIGITS(y);
if (ny == 0 && yds[0] == 0) rb_num_zerodiv(); 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 (divp) *divp = rb_int2big(0);
if (modp) *modp = x; if (modp) *modp = x;
return; return;

View File

@ -137,10 +137,10 @@ void xfree _((void*));
#define EXTERN extern #define EXTERN extern
#endif #endif
#if defined(sparc) || defined(__sparc__)
static inline void static inline void
flush_register_windows(void) flush_register_windows(void)
{ {
#if defined(sparc) || defined(__sparc__)
# if defined(__sparc_v9__) || defined(__arch64__) # if defined(__sparc_v9__) || defined(__arch64__)
asm volatile ("flushw" : :); asm volatile ("flushw" : :);
# elif defined(linux) || defined(__linux__) # elif defined(linux) || defined(__linux__)
@ -148,11 +148,9 @@ flush_register_windows(void)
# else /* Solaris, OpenBSD, NetBSD, etc. */ # else /* Solaris, OpenBSD, NetBSD, etc. */
asm volatile ("ta 0x03"); asm volatile ("ta 0x03");
# endif /* trap always to flush register windows if we are on a Sparc system */ # endif /* trap always to flush register windows if we are on a Sparc system */
#endif
} }
#define FLUSH_REGISTER_WINDOWS flush_register_windows() #define FLUSH_REGISTER_WINDOWS flush_register_windows()
#else /* Not a sparc, so */
#define FLUSH_REGISTER_WINDOWS NULL
#endif
#if defined(DOSISH) #if defined(DOSISH)
#define PATH_SEP ";" #define PATH_SEP ";"

3
enum.c
View File

@ -541,11 +541,10 @@ enum_zip(argc, argv, obj)
VALUE *argv; VALUE *argv;
VALUE obj; VALUE obj;
{ {
int i, j, len; int i;
VALUE result; VALUE result;
NODE *memo; NODE *memo;
len = 0;
for (i=0; i<argc; i++) { for (i=0; i<argc; i++) {
argv[i] = rb_convert_type(argv[i], T_ARRAY, "Array", "to_ary"); argv[i] = rb_convert_type(argv[i], T_ARRAY, "Array", "to_ary");
} }

13
eval.c
View File

@ -938,7 +938,7 @@ static void call_trace_func _((char*,NODE*,VALUE,ID,VALUE));
#define SET_CURRENT_SOURCE() (ruby_sourcefile = ruby_current_node->nd_file, \ #define SET_CURRENT_SOURCE() (ruby_sourcefile = ruby_current_node->nd_file, \
ruby_sourceline = nd_line(ruby_current_node)) ruby_sourceline = nd_line(ruby_current_node))
#else #else
#define SET_CURRENT_SOURCE() 0 #define SET_CURRENT_SOURCE() do { } while (0)
#endif #endif
void void
@ -2050,14 +2050,14 @@ is_defined(self, node, buf)
case NODE_NTH_REF: case NODE_NTH_REF:
if (RTEST(rb_reg_nth_defined(node->nd_nth, MATCH_DATA))) { 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; return buf;
} }
break; break;
case NODE_BACK_REF: case NODE_BACK_REF:
if (RTEST(rb_reg_nth_defined(0, MATCH_DATA))) { if (RTEST(rb_reg_nth_defined(0, MATCH_DATA))) {
sprintf(buf, "$%c", node->nd_nth); sprintf(buf, "$%c", (char)node->nd_nth);
return buf; return buf;
} }
break; break;
@ -3533,7 +3533,6 @@ static VALUE
rb_mod_public_method_defined(mod, mid) rb_mod_public_method_defined(mod, mid)
VALUE mod, mid; VALUE mod, mid;
{ {
VALUE klass;
ID id = rb_to_id(mid); ID id = rb_to_id(mid);
int noex; int noex;
@ -3548,7 +3547,6 @@ static VALUE
rb_mod_private_method_defined(mod, mid) rb_mod_private_method_defined(mod, mid)
VALUE mod, mid; VALUE mod, mid;
{ {
VALUE klass;
ID id = rb_to_id(mid); ID id = rb_to_id(mid);
int noex; int noex;
@ -3563,7 +3561,6 @@ static VALUE
rb_mod_protected_method_defined(mod, mid) rb_mod_protected_method_defined(mod, mid)
VALUE mod, mid; VALUE mod, mid;
{ {
VALUE klass;
ID id = rb_to_id(mid); ID id = rb_to_id(mid);
int noex; int noex;
@ -4444,7 +4441,7 @@ rb_undefined(obj, id, argc, argv, call_status)
VALUE obj; VALUE obj;
ID id; ID id;
int argc; int argc;
VALUE*argv; const VALUE *argv;
int call_status; int call_status;
{ {
VALUE *nargv; VALUE *nargv;
@ -7005,7 +7002,7 @@ method_call(argc, argv, method)
VALUE *argv; VALUE *argv;
VALUE method; VALUE method;
{ {
VALUE result; VALUE result; /* OK */
struct METHOD *data; struct METHOD *data;
int state; int state;
volatile int safe = ruby_safe_level; volatile int safe = ruby_safe_level;

View File

@ -237,7 +237,6 @@ fdbm_select(argc, argv, obj)
datum key, val; datum key, val;
DBM *dbm; DBM *dbm;
struct dbmdata *dbmp; struct dbmdata *dbmp;
VALUE keystr, valstr;
if (argc > 0) { if (argc > 0) {
rb_raise(rb_eArgError, "wrong number arguments(%d for 0)", argc); rb_raise(rb_eArgError, "wrong number arguments(%d for 0)", argc);

View File

@ -554,8 +554,6 @@ rb_dl_malloc(VALUE self, VALUE size)
VALUE VALUE
rb_dl_strdup(VALUE self, VALUE str) rb_dl_strdup(VALUE self, VALUE str)
{ {
void *p;
str = rb_String(str); str = rb_String(str);
return rb_dlptr_new(strdup(RSTRING(str)->ptr), RSTRING(str)->len, dlfree); return rb_dlptr_new(strdup(RSTRING(str)->ptr), RSTRING(str)->len, dlfree);
} }

View File

@ -133,9 +133,6 @@ rb_dlhandle_sym(int argc, VALUE argv[], VALUE self)
VALUE sym, type; VALUE sym, type;
void (*func)(); void (*func)();
VALUE val; VALUE val;
struct sym_data *data;
int *ctypes;
int i, ctypes_len;
struct dl_handle *dlhandle; struct dl_handle *dlhandle;
void *handle; void *handle;
const char *name, *stype; const char *name, *stype;

View File

@ -178,7 +178,7 @@ rb_dlptr_s_allocate(VALUE klass)
static VALUE static VALUE
rb_dlptr_initialize(int argc, VALUE argv[], VALUE self) rb_dlptr_initialize(int argc, VALUE argv[], VALUE self)
{ {
VALUE ptr, sym, obj, size; VALUE ptr, sym, size;
struct ptr_data *data; struct ptr_data *data;
void *p = NULL; void *p = NULL;
freefunc_t f = NULL; freefunc_t f = NULL;
@ -279,7 +279,6 @@ VALUE
rb_dlptr_free_set(VALUE self, VALUE val) rb_dlptr_free_set(VALUE self, VALUE val)
{ {
struct ptr_data *data; struct ptr_data *data;
int i;
Data_Get_Struct(self, struct ptr_data, data); Data_Get_Struct(self, struct ptr_data, data);
@ -463,10 +462,9 @@ rb_dlptr_inspect(VALUE self)
{ {
struct ptr_data *data; struct ptr_data *data;
char str[1024]; char str[1024];
VALUE name;
Data_Get_Struct(self, struct ptr_data, data); 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); rb_class2name(CLASS_OF(self)), data, data->ptr, data->size, data->free);
return rb_str_new2(str); return rb_str_new2(str);
} }
@ -519,9 +517,8 @@ rb_dlptr_define_data_type(int argc, VALUE argv[], VALUE self)
{ {
VALUE data_type, type, rest, vid; VALUE data_type, type, rest, vid;
struct ptr_data *data; struct ptr_data *data;
int i, t, len, num; int i, t, num;
char *ctype; char *ctype;
long size;
rb_scan_args(argc, argv, "11*", &data_type, &type, &rest); rb_scan_args(argc, argv, "11*", &data_type, &type, &rest);
Data_Get_Struct(self, struct ptr_data, data); Data_Get_Struct(self, struct ptr_data, data);
@ -731,9 +728,8 @@ cary2ary(void *ptr, char t, int len)
VALUE VALUE
rb_dlptr_aref(int argc, VALUE argv[], VALUE self) rb_dlptr_aref(int argc, VALUE argv[], VALUE self)
{ {
VALUE val, key = Qnil, num = Qnil; VALUE key = Qnil, num = Qnil;
ID id; ID id;
int idx;
struct ptr_data *data; struct ptr_data *data;
int i; int i;
int offset; int offset;

View File

@ -145,7 +145,6 @@ VALUE
rb_dlsym_initialize(int argc, VALUE argv[], VALUE self) rb_dlsym_initialize(int argc, VALUE argv[], VALUE self)
{ {
VALUE addr, name, type; VALUE addr, name, type;
VALUE val;
struct sym_data *data; struct sym_data *data;
void *saddr; void *saddr;
const char *sname, *stype; const char *sname, *stype;
@ -266,7 +265,7 @@ rb_dlsym_inspect(VALUE self)
str_size = RSTRING(proto)->len + 100; str_size = RSTRING(proto)->len + 100;
str = dlmalloc(str_size); str = dlmalloc(str_size);
snprintf(str, str_size - 1, 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); sym, sym->func, RSTRING(proto)->ptr);
val = rb_tainted_str_new2(str); val = rb_tainted_str_new2(str);
dlfree(str); dlfree(str);

View File

@ -93,7 +93,7 @@ etc_getpwuid(argc, argv, obj)
VALUE obj; VALUE obj;
{ {
#if defined(HAVE_GETPWENT) #if defined(HAVE_GETPWENT)
VALUE id, ary; VALUE id;
int uid; int uid;
struct passwd *pwd; struct passwd *pwd;

View File

@ -3,6 +3,7 @@
#include <errno.h> #include <errno.h>
#include <stdio.h> #include <stdio.h>
#include <unistd.h>
#include <readline/readline.h> #include <readline/readline.h>
#include <readline/history.h> #include <readline/history.h>
@ -228,7 +229,6 @@ readline_s_set_basic_word_break_characters(self, str)
{ {
#ifdef READLINE_21_OR_LATER #ifdef READLINE_21_OR_LATER
static char *basic_word_break_characters = NULL; static char *basic_word_break_characters = NULL;
char *s;
StringValue(str); StringValue(str);
if (basic_word_break_characters == NULL) { if (basic_word_break_characters == NULL) {
@ -268,7 +268,6 @@ readline_s_set_completer_word_break_characters(self, str)
{ {
#ifdef READLINE_21_OR_LATER #ifdef READLINE_21_OR_LATER
static char *completer_word_break_characters = NULL; static char *completer_word_break_characters = NULL;
char *s;
StringValue(str); StringValue(str);
if (completer_word_break_characters == NULL) { if (completer_word_break_characters == NULL) {
@ -308,7 +307,6 @@ readline_s_set_basic_quote_characters(self, str)
{ {
#ifdef READLINE_21_OR_LATER #ifdef READLINE_21_OR_LATER
static char *basic_quote_characters = NULL; static char *basic_quote_characters = NULL;
char *s;
StringValue(str); StringValue(str);
if (basic_quote_characters == NULL) { if (basic_quote_characters == NULL) {
@ -348,7 +346,6 @@ readline_s_set_completer_quote_characters(self, str)
{ {
#ifdef READLINE_21_OR_LATER #ifdef READLINE_21_OR_LATER
static char *completer_quote_characters = NULL; static char *completer_quote_characters = NULL;
char *s;
StringValue(str); StringValue(str);
if (completer_quote_characters == NULL) { if (completer_quote_characters == NULL) {
@ -388,7 +385,6 @@ readline_s_set_filename_quote_characters(self, str)
{ {
#ifdef READLINE_21_OR_LATER #ifdef READLINE_21_OR_LATER
static char *filename_quote_characters = NULL; static char *filename_quote_characters = NULL;
char *s;
StringValue(str); StringValue(str);
if (filename_quote_characters == NULL) { if (filename_quote_characters == NULL) {

View File

@ -225,7 +225,6 @@ fsdbm_select(argc, argv, obj)
datum key, val; datum key, val;
DBM *dbm; DBM *dbm;
struct dbmdata *dbmp; struct dbmdata *dbmp;
VALUE keystr, valstr;
if (argc > 0) { if (argc > 0) {
rb_raise(rb_eArgError, "wrong number arguments(%d for 0)", argc); rb_raise(rb_eArgError, "wrong number arguments(%d for 0)", argc);

View File

@ -879,7 +879,7 @@ init_inetsock_internal(arg)
struct inetsock_arg *arg; struct inetsock_arg *arg;
{ {
int type = arg->type; int type = arg->type;
struct addrinfo hints, *res; struct addrinfo *res;
int fd, status; int fd, status;
char *syscall; char *syscall;
@ -972,8 +972,7 @@ tcp_init(argc, argv, sock)
VALUE remote_host, remote_serv; VALUE remote_host, remote_serv;
VALUE local_host, local_serv; VALUE local_host, local_serv;
int pcount = rb_scan_args(argc, argv, "22", rb_scan_args(argc, argv, "22", &remote_host, &remote_serv,
&remote_host, &remote_serv,
&local_host, &local_serv); &local_host, &local_serv);
return init_inetsock(sock, remote_host, remote_serv, return init_inetsock(sock, remote_host, remote_serv,
@ -1362,7 +1361,6 @@ udp_connect(sock, host, port)
VALUE sock, host, port; VALUE sock, host, port;
{ {
OpenFile *fptr; OpenFile *fptr;
int fd;
struct udp_arg arg; struct udp_arg arg;
VALUE ret; VALUE ret;
@ -2185,7 +2183,7 @@ sock_s_getnameinfo(argc, argv)
int error; int error;
struct sockaddr_storage ss; struct sockaddr_storage ss;
struct sockaddr *sap; struct sockaddr *sap;
char *ep, *ap; char *ap;
sa = flags = Qnil; sa = flags = Qnil;
rb_scan_args(argc, argv, "11", &sa, &flags); rb_scan_args(argc, argv, "11", &sa, &flags);

View File

@ -148,7 +148,7 @@ static VALUE strio_closed _((VALUE));
static VALUE strio_closed_read _((VALUE)); static VALUE strio_closed_read _((VALUE));
static VALUE strio_closed_write _((VALUE)); static VALUE strio_closed_write _((VALUE));
static VALUE strio_eof _((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_get_lineno _((VALUE));
static VALUE strio_set_lineno _((VALUE, VALUE)); static VALUE strio_set_lineno _((VALUE, VALUE));
static VALUE strio_get_pos _((VALUE)); static VALUE strio_get_pos _((VALUE));
@ -156,7 +156,7 @@ static VALUE strio_set_pos _((VALUE, VALUE));
static VALUE strio_rewind _((VALUE)); static VALUE strio_rewind _((VALUE));
static VALUE strio_seek _((int, VALUE *, VALUE)); static VALUE strio_seek _((int, VALUE *, VALUE));
static VALUE strio_get_sync _((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_each_byte _((VALUE));
static VALUE strio_getc _((VALUE)); static VALUE strio_getc _((VALUE));
static VALUE strio_ungetc _((VALUE, VALUE)); static VALUE strio_ungetc _((VALUE, VALUE));
@ -167,8 +167,8 @@ static VALUE strio_readline _((int, VALUE *, VALUE));
static VALUE strio_each _((int, VALUE *, VALUE)); static VALUE strio_each _((int, VALUE *, VALUE));
static VALUE strio_readlines _((int, VALUE *, VALUE)); static VALUE strio_readlines _((int, VALUE *, VALUE));
static VALUE strio_write _((VALUE, VALUE)); static VALUE strio_write _((VALUE, VALUE));
static VALUE strio_print _((int, VALUE *, VALUE)); /* static VALUE strio_print _((int, VALUE *, VALUE)); NOT USED */
static VALUE strio_printf _((int, VALUE *, VALUE)); /* static VALUE strio_printf _((int, VALUE *, VALUE)); NOT USED */
static VALUE strio_putc _((VALUE, VALUE)); static VALUE strio_putc _((VALUE, VALUE));
static VALUE strio_read _((int, VALUE *, VALUE)); static VALUE strio_read _((int, VALUE *, VALUE));
static VALUE strio_size _((VALUE)); static VALUE strio_size _((VALUE));

View File

@ -54,7 +54,6 @@ static VALUE mSyslog_close(VALUE self)
static VALUE mSyslog_open(int argc, VALUE *argv, VALUE self) static VALUE mSyslog_open(int argc, VALUE *argv, VALUE self)
{ {
VALUE ident, opt, fac; VALUE ident, opt, fac;
int mask;
if (syslog_opened) { if (syslog_opened) {
rb_raise(rb_eRuntimeError, "syslog already open"); rb_raise(rb_eRuntimeError, "syslog already open");

2
gc.c
View File

@ -879,7 +879,7 @@ gc_sweep()
RVALUE *p, *pend, *final_list; RVALUE *p, *pend, *final_list;
int freed = 0; int freed = 0;
int i, j; int i, j;
unsigned long live = 0, garbage = 0; unsigned long live = 0;
if (ruby_in_compile && ruby_parser_stack_on_heap()) { if (ruby_in_compile && ruby_parser_stack_on_heap()) {
/* should not reclaim nodes during compilation /* should not reclaim nodes during compilation

View File

@ -391,7 +391,7 @@ stmt : kALIAS fitem {lex_state = EXPR_FNAME;} fitem
{ {
char buf[3]; char buf[3];
sprintf(buf, "$%c", $3->nd_nth); sprintf(buf, "$%c", (char)$3->nd_nth);
$$ = NEW_VALIAS($2, rb_intern(buf)); $$ = NEW_VALIAS($2, rb_intern(buf));
} }
| kALIAS tGVAR tNTH_REF | kALIAS tGVAR tNTH_REF
@ -3134,7 +3134,7 @@ whole_match_p(eos, len, indent)
while (*p && ISSPACE(*p)) p++; while (*p && ISSPACE(*p)) p++;
} }
n= lex_pend - (p + len); 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; if (strncmp(eos, p, len) == 0) return Qtrue;
return Qfalse; return Qfalse;
} }

View File

@ -285,12 +285,12 @@ range_step(argc, argv, range)
return range; return range;
} }
static void static VALUE
each_i(v, arg) each_i(v, arg)
VALUE v; VALUE v;
void *arg; void *arg;
{ {
rb_yield(v); return rb_yield(v);
} }
static VALUE static VALUE
@ -324,7 +324,7 @@ range_each(range)
rb_iterate((VALUE(*)_((VALUE)))str_step, (VALUE)args, step_i, (VALUE)iter); rb_iterate((VALUE(*)_((VALUE)))str_step, (VALUE)args, step_i, (VALUE)iter);
} }
else { else {
range_each_func(range, each_i, beg, end, 0); range_each_func(range, each_i, beg, end, NULL);
} }
return range; return range;
} }

2
ruby.c
View File

@ -618,7 +618,7 @@ proc_options(argc, argv)
goto reswitch; goto reswitch;
case '-': case '-':
if (!s[1] || s[1] == '\r' && !s[2]) { if (!s[1] || (s[1] == '\r' && !s[2])) {
argc--,argv++; argc--,argv++;
goto switch_end; goto switch_end;
} }