summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormichal <michal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-01-16 07:38:40 +0000
committermichal <michal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-01-16 07:38:40 +0000
commit4e13d36561868d78e9e5ff9b24aba67d418c67ed (patch)
tree07808bdd94888f12e0e1b1a6f52777f213d50b91
parent9df466b287471d386f962ea41cf49c40f2059c8b (diff)
-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
-rw-r--r--bignum.c8
-rw-r--r--defines.h6
-rw-r--r--enum.c3
-rw-r--r--eval.c13
-rw-r--r--ext/dbm/dbm.c1
-rw-r--r--ext/dl/dl.c2
-rw-r--r--ext/dl/handle.c3
-rw-r--r--ext/dl/ptr.c12
-rw-r--r--ext/dl/sym.c3
-rw-r--r--ext/etc/etc.c2
-rw-r--r--ext/readline/readline.c6
-rw-r--r--ext/sdbm/init.c1
-rw-r--r--ext/socket/socket.c12
-rw-r--r--ext/stringio/stringio.c8
-rw-r--r--ext/syslog/syslog.c1
-rw-r--r--gc.c2
-rw-r--r--hash.c2
-rw-r--r--parse.y4
-rw-r--r--range.c6
-rw-r--r--ruby.c2
20 files changed, 35 insertions, 62 deletions
diff --git a/bignum.c b/bignum.c
index 99bed7377a..c010bf7046 100644
--- a/bignum.c
+++ b/bignum.c
@@ -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;
diff --git a/defines.h b/defines.h
index 681a20db7d..81ed18a341 100644
--- a/defines.h
+++ b/defines.h
@@ -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 ";"
diff --git a/enum.c b/enum.c
index 92bb57dc8d..6b76f4f710 100644
--- a/enum.c
+++ b/enum.c
@@ -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");
}
diff --git a/eval.c b/eval.c
index 5cf981bfea..70e2d8548a 100644
--- a/eval.c
+++ b/eval.c
@@ -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, \
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;
@@ -3533,7 +3533,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 +3547,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 +3561,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 +4441,7 @@ rb_undefined(obj, id, argc, argv, call_status)
VALUE obj;
ID id;
int argc;
- VALUE*argv;
+ const VALUE *argv;
int call_status;
{
VALUE *nargv;
@@ -7005,7 +7002,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;
diff --git a/ext/dbm/dbm.c b/ext/dbm/dbm.c
index c122f5a2b4..ad84589640 100644
--- a/ext/dbm/dbm.c
+++ b/ext/dbm/dbm.c
@@ -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);
diff --git a/ext/dl/dl.c b/ext/dl/dl.c
index c1e5311c0a..0d806a7de7 100644
--- a/ext/dl/dl.c
+++ b/ext/dl/dl.c
@@ -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);
}
diff --git a/ext/dl/handle.c b/ext/dl/handle.c
index 689ce4e3a5..23ad5ef066 100644
--- a/ext/dl/handle.c
+++ b/ext/dl/handle.c
@@ -133,9 +133,6 @@ rb_dlhandle_sym(int argc, VALUE argv[], VALUE self)
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;
diff --git a/ext/dl/ptr.c b/ext/dl/ptr.c
index 8c2799a2b2..60f4ad00ed 100644
--- a/ext/dl/ptr.c
+++ b/ext/dl/ptr.c
@@ -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, VALUE argv[], VALUE self)
{
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;
diff --git a/ext/dl/sym.c b/ext/dl/sym.c
index b5de3b961f..95a813cc1f 100644
--- a/ext/dl/sym.c
+++ b/ext/dl/sym.c
@@ -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);
diff --git a/ext/etc/etc.c b/ext/etc/etc.c
index b10943458d..ea8cb61802 100644
--- a/ext/etc/etc.c
+++ b/ext/etc/etc.c
@@ -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;
diff --git a/ext/readline/readline.c b/ext/readline/readline.c
index 2f460ea3e0..fc17dad4f1 100644
--- a/ext/readline/readline.c
+++ b/ext/readline/readline.c
@@ -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_characters(self, str)
{
#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_characters(self, str)
{
#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(self, str)
{
#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_characters(self, str)
{
#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(self, str)
{
#ifdef READLINE_21_OR_LATER
static char *filename_quote_characters = NULL;
- char *s;
StringValue(str);
if (filename_quote_characters == NULL) {
diff --git a/ext/sdbm/init.c b/ext/sdbm/init.c
index a2b90438f6..f20e3cfa58 100644
--- a/ext/sdbm/init.c
+++ b/ext/sdbm/init.c
@@ -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);
diff --git a/ext/socket/socket.c b/ext/socket/socket.c
index d0838b1580..6cdedd22e0 100644
--- a/ext/socket/socket.c
+++ b/ext/socket/socket.c
@@ -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);
diff --git a/ext/stringio/stringio.c b/ext/stringio/stringio.c
index 6369d10589..93d7460daf 100644
--- a/ext/stringio/stringio.c
+++ b/ext/stringio/stringio.c
@@ -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, VALUE));
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, VALUE *, VALUE));
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));
diff --git a/ext/syslog/syslog.c b/ext/syslog/syslog.c
index 3e86569f06..5ee2c6b89a 100644
--- a/ext/syslog/syslog.c
+++ b/ext/syslog/syslog.c
@@ -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");
diff --git a/gc.c b/gc.c
index 554a87b86b..ee52108d7e 100644
--- a/gc.c
+++ b/gc.c
@@ -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
diff --git a/hash.c b/hash.c
index 3acbedde19..257a4c8e47 100644
--- a/hash.c
+++ b/hash.c
@@ -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;
diff --git a/parse.y b/parse.y
index 13465631dc..723c239ead 100644
--- a/parse.y
+++ b/parse.y
@@ -391,7 +391,7 @@ stmt : kALIAS fitem {lex_state = EXPR_FNAME;} fitem
{
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;
}
diff --git a/range.c b/range.c
index 11b3b985bd..1ce4aae746 100644
--- a/range.c
+++ b/range.c
@@ -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;
}
diff --git a/ruby.c b/ruby.c
index 006387162b..878829a742 100644
--- a/ruby.c
+++ b/ruby.c
@@ -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;
}