diff --git a/ChangeLog b/ChangeLog index 99ed9d3c4a..23269bed4d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +Mon Apr 25 16:43:45 2011 NARUSE, Yui + + * random.c (random_rand): remove unused variables. + + * struct.c (rb_struct_define_without_accessor): ditto. + + * strftime.c (rb_strftime_with_timespec): ditto. + + * sprintf.c: ditto. + + * time.c (time_asctime): remove useless GetTimeval(). + + * thread_pthread.c: cast to (void *) for %p. + Mon Apr 25 11:02:11 2011 NARUSE, Yui * ext/ripper/lib/ripper/sexp.rb: fix rdoc arround sexp. diff --git a/random.c b/random.c index e711d283f1..ab9e42918f 100644 --- a/random.c +++ b/random.c @@ -1136,8 +1136,7 @@ static VALUE random_rand(int argc, VALUE *argv, VALUE obj) { rb_random_t *rnd = get_rnd(obj); - VALUE vmax, beg = Qundef, end = Qundef, v; - int excl = 0; + VALUE vmax, v; if (argc == 0) { return rb_float_new(genrand_real(&rnd->mt)); diff --git a/sprintf.c b/sprintf.c index 89ce474089..becc25b2d2 100644 --- a/sprintf.c +++ b/sprintf.c @@ -30,9 +30,7 @@ static void fmt_setup(char*,size_t,int,int,int,int); static char* remove_sign_bits(char *str, int base) { - char *s, *t; - - s = t = str; + char *t = str; if (base == 16) { while (*t == 'f') { @@ -746,7 +744,7 @@ rb_str_format(int argc, const VALUE *argv, VALUE fmt) char sc = 0; long v = 0; int base, bignum = 0; - int len, pos; + int len; switch (*p) { case 'd': @@ -910,7 +908,6 @@ rb_str_format(int argc, const VALUE *argv, VALUE fmt) len = rb_long2int(RSTRING_END(tmp) - s); } - pos = -1; if (dots) { prec -= 2; width -= 2; diff --git a/strftime.c b/strftime.c index 9d9f48d0de..8b6473ce38 100644 --- a/strftime.c +++ b/strftime.c @@ -689,17 +689,15 @@ rb_strftime_with_timespec(char *s, size_t maxsize, const char *format, const str subsec = div(subsec, INT2FIX(1)); if (FIXNUM_P(subsec)) { - int l; - l = snprintf(s, endp - s, "%0*ld", precision, FIX2LONG(subsec)); + (void)snprintf(s, endp - s, "%0*ld", precision, FIX2LONG(subsec)); s += precision; } else { VALUE args[2], result; - size_t l; args[0] = INT2FIX(precision); args[1] = subsec; result = rb_str_format(2, args, rb_str_new2("%0*d")); - l = strlcpy(s, StringValueCStr(result), endp-s); + (void)strlcpy(s, StringValueCStr(result), endp-s); s += precision; } } diff --git a/struct.c b/struct.c index 78f836f8f5..5572a92135 100644 --- a/struct.c +++ b/struct.c @@ -240,12 +240,10 @@ rb_struct_define_without_accessor(const char *class_name, VALUE super, rb_alloc_ VALUE klass; va_list ar; VALUE members; - long i; char *name; members = rb_ary_new2(0); va_start(ar, alloc); - i = 0; while ((name = va_arg(ar, char*)) != NULL) { rb_ary_push(members, ID2SYM(rb_intern(name))); } diff --git a/thread_pthread.c b/thread_pthread.c index ad6f716a3f..f60da8ab7e 100644 --- a/thread_pthread.c +++ b/thread_pthread.c @@ -43,7 +43,7 @@ gvl_show_waiting_threads(rb_vm_t *vm) rb_thread_t *th = vm->gvl.waiting_threads; int i = 0; while (th) { - fprintf(stderr, "waiting (%d): %p\n", i++, th); + fprintf(stderr, "waiting (%d): %p\n", i++, (void *)th); th = th->native_thread_data.gvl_next; } } @@ -82,7 +82,7 @@ gvl_acquire(rb_vm_t *vm, rb_thread_t *th) #else native_mutex_lock(&vm->gvl.lock); if (vm->gvl.waiting > 0 || vm->gvl.acquired != 0) { - if (GVL_DEBUG) fprintf(stderr, "gvl acquire (%p): sleep\n", th); + if (GVL_DEBUG) fprintf(stderr, "gvl acquire (%p): sleep\n", (void *)th); gvl_waiting_push(vm, th); if (GVL_DEBUG) gvl_show_waiting_threads(vm); @@ -98,7 +98,7 @@ gvl_acquire(rb_vm_t *vm, rb_thread_t *th) native_mutex_unlock(&vm->gvl.lock); #endif if (GVL_DEBUG) gvl_show_waiting_threads(vm); - if (GVL_DEBUG) fprintf(stderr, "gvl acquire (%p): acquire\n", th); + if (GVL_DEBUG) fprintf(stderr, "gvl acquire (%p): acquire\n", (void *)th); } static void @@ -110,11 +110,11 @@ gvl_release(rb_vm_t *vm) native_mutex_lock(&vm->gvl.lock); if (vm->gvl.waiting > 0) { rb_thread_t *th = vm->gvl.waiting_threads; - if (GVL_DEBUG) fprintf(stderr, "gvl release (%p): wakeup: %p\n", GET_THREAD(), th); + if (GVL_DEBUG) fprintf(stderr, "gvl release (%p): wakeup: %p\n", (void *)GET_THREAD(), (void *)th); native_cond_signal(&th->native_thread_data.gvl_cond); } else { - if (GVL_DEBUG) fprintf(stderr, "gvl release (%p): wakeup: %p\n", GET_THREAD(), NULL); + if (GVL_DEBUG) fprintf(stderr, "gvl release (%p): wakeup: %p\n", (void *)GET_THREAD(), NULL); /* do nothing */ } vm->gvl.acquired = 0; @@ -163,7 +163,7 @@ mutex_debug(const char *msg, pthread_mutex_t *lock) static pthread_mutex_t dbglock = PTHREAD_MUTEX_INITIALIZER; if ((r = pthread_mutex_lock(&dbglock)) != 0) {exit(1);} - fprintf(stdout, "%s: %p\n", msg, lock); + fprintf(stdout, "%s: %p\n", msg, (void *)lock); if ((r = pthread_mutex_unlock(&dbglock)) != 0) {exit(1);} } } diff --git a/time.c b/time.c index 6107c8dd6e..2c6104a501 100644 --- a/time.c +++ b/time.c @@ -3629,9 +3629,6 @@ static VALUE strftimev(const char *fmt, VALUE time); static VALUE time_asctime(VALUE time) { - struct time_object *tobj; - - GetTimeval(time, tobj); return strftimev("%a %b %e %T %Y", time); }