зеркало из https://github.com/github/ruby.git
-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:
Родитель
9df466b287
Коммит
4e13d36561
8
bignum.c
8
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;
|
||||
|
|
|
@ -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 ";"
|
||||
|
|
3
enum.c
3
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");
|
||||
}
|
||||
|
|
13
eval.c
13
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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
12
ext/dl/ptr.c
12
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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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");
|
||||
|
|
2
gc.c
2
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
|
||||
|
|
2
hash.c
2
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;
|
||||
|
|
4
parse.y
4
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;
|
||||
}
|
||||
|
|
6
range.c
6
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;
|
||||
}
|
||||
|
|
2
ruby.c
2
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;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче