From 2e54fe9d4dd4569032590d0cf1bcea472d422c91 Mon Sep 17 00:00:00 2001 From: nobu Date: Tue, 10 Mar 2009 05:43:14 +0000 Subject: [PATCH] * array.c, bignum.c, gc.c, numeric.c, string.c, util.c, insns.def, missing/crypt.c, missing/vsnprintf.c, : suppress warnings. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22872 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ array.c | 18 +++++++++--------- bignum.c | 7 ++++--- gc.c | 8 ++++---- insns.def | 4 ++-- missing/crypt.c | 4 ++-- missing/vsnprintf.c | 2 +- numeric.c | 8 ++++---- string.c | 2 +- util.c | 6 +++--- 10 files changed, 35 insertions(+), 29 deletions(-) diff --git a/ChangeLog b/ChangeLog index 038f77eedf..3b65e8bb0a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Tue Mar 10 14:43:16 2009 Nobuyoshi Nakada + + * array.c, bignum.c, gc.c, numeric.c, string.c, util.c, insns.def, + missing/crypt.c, missing/vsnprintf.c, : suppress warnings. + Tue Mar 10 13:45:54 2009 Nobuyoshi Nakada * win32/Makefile.sub (LDFLAGS): moved -link to TRY_LINK, LINK_SO diff --git a/array.c b/array.c index d88b369103..cc4942597f 100644 --- a/array.c +++ b/array.c @@ -3383,7 +3383,7 @@ rb_ary_shuffle_bang(VALUE ary) rb_ary_modify(ary); while (i) { - long j = rb_genrand_real()*i; + long j = (long)(rb_genrand_real()*i); VALUE tmp = RARRAY_PTR(ary)[--i]; RARRAY_PTR(ary)[i] = RARRAY_PTR(ary)[j]; RARRAY_PTR(ary)[j] = tmp; @@ -3432,7 +3432,7 @@ rb_ary_sample(int argc, VALUE *argv, VALUE ary) len = RARRAY_LEN(ary); if (argc == 0) { if (len == 0) return Qnil; - i = len == 1 ? 0 : rb_genrand_real()*len; + i = len == 1 ? 0 : (long)(rb_genrand_real()*len); return RARRAY_PTR(ary)[i]; } rb_scan_args(argc, argv, "1", &nv); @@ -3445,14 +3445,14 @@ rb_ary_sample(int argc, VALUE *argv, VALUE ary) case 1: return rb_ary_new4(1, &ptr[(long)(rb_genrand_real()*len)]); case 2: - i = rb_genrand_real()*len; - j = rb_genrand_real()*(len-1); + i = (long)(rb_genrand_real()*len); + j = (long)(rb_genrand_real()*(len-1)); if (j >= i) j++; return rb_ary_new3(2, ptr[i], ptr[j]); case 3: - i = rb_genrand_real()*len; - j = rb_genrand_real()*(len-1); - k = rb_genrand_real()*(len-2); + i = (long)(rb_genrand_real()*len); + j = (long)(rb_genrand_real()*(len-1)); + k = (long)(rb_genrand_real()*(len-2)); { long l = j, g = i; if (j >= i) l = i, g = ++j; @@ -3462,9 +3462,9 @@ rb_ary_sample(int argc, VALUE *argv, VALUE ary) } if (n < sizeof(idx)/sizeof(idx[0])) { long sorted[sizeof(idx)/sizeof(idx[0])]; - sorted[0] = idx[0] = rb_genrand_real()*len; + sorted[0] = idx[0] = (long)(rb_genrand_real()*len); for (i=1; i heaps_length) { @@ -1712,8 +1712,8 @@ gc_sweep(rb_objspace_t *objspace) size_t i; size_t live = 0, free_min = 0, do_heap_free = 0; - do_heap_free = (heaps_used * HEAP_OBJ_LIMIT) * 0.65; - free_min = (heaps_used * HEAP_OBJ_LIMIT) * 0.2; + do_heap_free = (size_t)((heaps_used * HEAP_OBJ_LIMIT) * 0.65); + free_min = (size_t)((heaps_used * HEAP_OBJ_LIMIT) * 0.2); if (free_min < FREE_MIN) { do_heap_free = heaps_used * HEAP_OBJ_LIMIT; @@ -1776,7 +1776,7 @@ gc_sweep(rb_objspace_t *objspace) } GC_PROF_SET_MALLOC_INFO; if (malloc_increase > malloc_limit) { - malloc_limit += (malloc_increase - malloc_limit) * (double)live / (live + freed); + malloc_limit += (size_t)((malloc_increase - malloc_limit) * (double)live / (live + freed)); if (malloc_limit < GC_MALLOC_LIMIT) malloc_limit = GC_MALLOC_LIMIT; } malloc_increase = 0; diff --git a/insns.def b/insns.def index f82c5db326..bc93010523 100644 --- a/insns.def +++ b/insns.def @@ -977,7 +977,7 @@ DEFINE_INSN send (ID op_id, rb_num_t op_argc, ISEQ blockiseq, rb_num_t op_flag, IC ic) (...) -(VALUE val) // inc += - (op_argc + ((op_flag & VM_CALL_ARGS_BLOCKARG_BIT) ? 1 : 0)); +(VALUE val) // inc += - (int)(op_argc + ((op_flag & VM_CALL_ARGS_BLOCKARG_BIT) ? 1 : 0)); { NODE *mn; VALUE recv, klass; @@ -1011,7 +1011,7 @@ DEFINE_INSN invokesuper (rb_num_t op_argc, ISEQ blockiseq, rb_num_t op_flag) (...) -(VALUE val) // inc += - (op_argc + ((op_flag & VM_CALL_ARGS_BLOCKARG_BIT) ? 1 : 0)); +(VALUE val) // inc += - (int)(op_argc + ((op_flag & VM_CALL_ARGS_BLOCKARG_BIT) ? 1 : 0)); { rb_block_t *blockptr = !(op_flag & VM_CALL_ARGS_BLOCKARG_BIT) ? GET_BLOCK_PTR() : 0; int num = caller_setup_args(th, GET_CFP(), op_flag, op_argc, blockiseq, &blockptr); diff --git a/missing/crypt.c b/missing/crypt.c index 32736bccfb..5245abd338 100644 --- a/missing/crypt.c +++ b/missing/crypt.c @@ -680,13 +680,13 @@ des_cipher(in, out, salt, num_iter) if (num_iter >= 0) { /* encryption */ kp = &KS[0]; - ks_inc = sizeof(*kp); + ks_inc = (int)sizeof(*kp); } else { /* decryption */ num_iter = -num_iter; kp = &KS[KS_SIZE-1]; - ks_inc = -sizeof(*kp); + ks_inc = -(int)sizeof(*kp); } while (--num_iter >= 0) { diff --git a/missing/vsnprintf.c b/missing/vsnprintf.c index 9d0e626946..d8dd110bbc 100644 --- a/missing/vsnprintf.c +++ b/missing/vsnprintf.c @@ -750,7 +750,7 @@ reswitch: switch (ch) { { ulval = SARG(); if ((long)ulval < 0) { - ulval = -ulval; + ulval = (u_long)(-(long)ulval); sign = '-'; } } diff --git a/numeric.c b/numeric.c index bb55485669..fc0b7175ca 100644 --- a/numeric.c +++ b/numeric.c @@ -1272,7 +1272,7 @@ flo_floor(VALUE num) if (!FIXABLE(f)) { return rb_dbl2big(f); } - val = f; + val = (long)f; return LONG2FIX(val); } @@ -1298,7 +1298,7 @@ flo_ceil(VALUE num) if (!FIXABLE(f)) { return rb_dbl2big(f); } - val = f; + val = (long)f; return LONG2FIX(val); } @@ -1347,7 +1347,7 @@ flo_round(int argc, VALUE *argv, VALUE num) if (!FIXABLE(number)) { return rb_dbl2big(number); } - val = number; + val = (long)number; return LONG2FIX(val); } @@ -1372,7 +1372,7 @@ flo_truncate(VALUE num) if (!FIXABLE(f)) { return rb_dbl2big(f); } - val = f; + val = (long)f; return LONG2FIX(val); } diff --git a/string.c b/string.c index d464d5f562..950a4315aa 100644 --- a/string.c +++ b/string.c @@ -4872,7 +4872,7 @@ tr_trans(VALUE str, VALUE src, VALUE repl, int sflag) } } else { - int clen, tlen, max = RSTRING_LEN(str) * 1.2; + int clen, tlen, max = (int)(RSTRING_LEN(str) * 1.2); int offset; char *buf = ALLOC_N(char, max), *t = buf; diff --git a/util.c b/util.c index 50ddb2b315..97504ffff4 100644 --- a/util.c +++ b/util.c @@ -162,7 +162,7 @@ ruby_strtoul(const char *str, char **endptr, int base) } if (sign < 0) { - ret = -ret; + ret = (unsigned long)(-(long)ret); return ret; } else { @@ -2821,7 +2821,7 @@ drop_down: #ifdef Avoid_Underflow if (scale && y <= 2*P*Exp_msk1) { if (aadj <= 0x7fffffff) { - if ((z = aadj) <= 0) + if ((z = (int)aadj) <= 0) z = 1; aadj = z; dval(aadj1) = dsign ? aadj : -aadj; @@ -3428,7 +3428,7 @@ ruby_dtoa(double d_, int mode, int ndigits, int *decpt, int *sign, char **rve) */ dval(eps) = 0.5/tens[ilim-1] - dval(eps); for (i = 0;;) { - L = dval(d); + L = (int)dval(d); dval(d) -= L; *s++ = '0' + (int)L; if (dval(d) < dval(eps))