1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* 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
This commit is contained in:
nobu 2009-03-10 05:43:14 +00:00
parent f8147318dd
commit 2e54fe9d4d
10 changed files with 35 additions and 29 deletions

View file

@ -1,3 +1,8 @@
Tue Mar 10 14:43:16 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
* 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 <nobu@ruby-lang.org>
* win32/Makefile.sub (LDFLAGS): moved -link to TRY_LINK, LINK_SO

18
array.c
View file

@ -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<n; i++) {
k = rb_genrand_real()*--len;
k = (long)(rb_genrand_real()*--len);
for (j = 0; j < i; ++j) {
if (k < sorted[j]) break;
++k;

View file

@ -1025,7 +1025,7 @@ rb_big2ulong_pack(VALUE x)
{
VALUE num = big2ulong(x, "unsigned long", Qfalse);
if (!RBIGNUM_SIGN(x)) {
return -num;
return (VALUE)(-(SIGNED_VALUE)num);
}
return num;
}
@ -1039,7 +1039,7 @@ rb_big2ulong(VALUE x)
if ((SIGNED_VALUE)num < 0) {
rb_raise(rb_eRangeError, "bignum out of range of unsigned long");
}
return -num;
return (VALUE)(-(SIGNED_VALUE)num);
}
return num;
}
@ -1082,7 +1082,8 @@ rb_big2ull(VALUE x)
{
unsigned LONG_LONG num = big2ull(x, "unsigned long long");
if (!RBIGNUM_SIGN(x)) return -num;
if (!RBIGNUM_SIGN(x))
return (VALUE)(-(SIGNED_VALUE)num);
return num;
}

8
gc.c
View file

@ -937,7 +937,7 @@ init_heap(rb_objspace_t *objspace)
static void
set_heaps_increment(rb_objspace_t *objspace)
{
size_t next_heaps_length = heaps_used * 1.8;
size_t next_heaps_length = (size_t)(heaps_used * 1.8);
heaps_inc = next_heaps_length - heaps_used;
if (next_heaps_length > 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;

View file

@ -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);

View file

@ -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) {

View file

@ -750,7 +750,7 @@ reswitch: switch (ch) {
{
ulval = SARG();
if ((long)ulval < 0) {
ulval = -ulval;
ulval = (u_long)(-(long)ulval);
sign = '-';
}
}

View file

@ -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);
}

View file

@ -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;

6
util.c
View file

@ -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))