suppress integer overflow warnings
* random.c: annotate rb_hash_start with NO_SANITIZE (seed.key.hash + h overflows and that seems intentional) * bignum.c: avoid (size_t)-- * cont.c: ditto * util.c: ditto * vm_insnhelper.c: ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65688 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
803dcea481
commit
7f6691ae77
7
bignum.c
7
bignum.c
@ -2587,10 +2587,9 @@ bigdivrem_single1(BDIGIT *qds, const BDIGIT *xds, size_t xn, BDIGIT x_higher_bdi
|
|||||||
size_t i;
|
size_t i;
|
||||||
BDIGIT_DBL t2;
|
BDIGIT_DBL t2;
|
||||||
t2 = x_higher_bdigit;
|
t2 = x_higher_bdigit;
|
||||||
i = xn;
|
for (i = 0; i < xn; i++) {
|
||||||
while (i--) {
|
t2 = BIGUP(t2) + xds[xn - i - 1];
|
||||||
t2 = BIGUP(t2) + xds[i];
|
qds[xn - i - 1] = (BDIGIT)(t2 / y);
|
||||||
qds[i] = (BDIGIT)(t2 / y);
|
|
||||||
t2 %= y;
|
t2 %= y;
|
||||||
}
|
}
|
||||||
return (BDIGIT)t2;
|
return (BDIGIT)t2;
|
||||||
|
8
cont.c
8
cont.c
@ -1199,7 +1199,7 @@ rollback_ensure_stack(VALUE self,rb_ensure_list_t *current,rb_ensure_entry_t *ta
|
|||||||
{
|
{
|
||||||
rb_ensure_list_t *p;
|
rb_ensure_list_t *p;
|
||||||
rb_ensure_entry_t *entry;
|
rb_ensure_entry_t *entry;
|
||||||
size_t i;
|
size_t i, j;
|
||||||
size_t cur_size;
|
size_t cur_size;
|
||||||
size_t target_size;
|
size_t target_size;
|
||||||
size_t base_point;
|
size_t base_point;
|
||||||
@ -1237,10 +1237,10 @@ rollback_ensure_stack(VALUE self,rb_ensure_list_t *current,rb_ensure_entry_t *ta
|
|||||||
cur_size--;
|
cur_size--;
|
||||||
}
|
}
|
||||||
/* push ensure stack */
|
/* push ensure stack */
|
||||||
while (i--) {
|
for (j = 0; j < i; j++) {
|
||||||
func = (VALUE (*)(ANYARGS)) lookup_rollback_func(target[i].e_proc);
|
func = (VALUE (*)(ANYARGS)) lookup_rollback_func(target[i - j - 1].e_proc);
|
||||||
if ((VALUE)func != Qundef) {
|
if ((VALUE)func != Qundef) {
|
||||||
(*func)(target[i].data2);
|
(*func)(target[i - j - 1].data2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
1
random.c
1
random.c
@ -1573,6 +1573,7 @@ init_seed(struct MT *mt)
|
|||||||
seed.u32[i] = genrand_int32(mt);
|
seed.u32[i] = genrand_int32(mt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NO_SANITIZE("unsigned-integer-overflow", extern st_index_t rb_hash_start(st_index_t h));
|
||||||
st_index_t
|
st_index_t
|
||||||
rb_hash_start(st_index_t h)
|
rb_hash_start(st_index_t h)
|
||||||
{
|
{
|
||||||
|
10
util.c
10
util.c
@ -54,8 +54,16 @@ ruby_scan_hex(const char *start, size_t len, size_t *retlen)
|
|||||||
register const char *s = start;
|
register const char *s = start;
|
||||||
register unsigned long retval = 0;
|
register unsigned long retval = 0;
|
||||||
const char *tmp;
|
const char *tmp;
|
||||||
|
size_t i = 0;
|
||||||
|
|
||||||
while (len-- && *s && (tmp = strchr(hexdigit, *s))) {
|
for (i = 0; i < len; i++) {
|
||||||
|
if (! s[0]) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
tmp = strchr(hexdigit, *s);
|
||||||
|
if (! tmp) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
retval <<= 4;
|
retval <<= 4;
|
||||||
retval |= (tmp - hexdigit) & 15;
|
retval |= (tmp - hexdigit) & 15;
|
||||||
s++;
|
s++;
|
||||||
|
@ -3211,7 +3211,7 @@ vm_opt_newarray_max(rb_num_t num, const VALUE *ptr)
|
|||||||
else {
|
else {
|
||||||
struct cmp_opt_data cmp_opt = { 0, 0 };
|
struct cmp_opt_data cmp_opt = { 0, 0 };
|
||||||
VALUE result = *ptr;
|
VALUE result = *ptr;
|
||||||
rb_num_t i = num - 1;
|
rb_snum_t i = num - 1;
|
||||||
while (i-- > 0) {
|
while (i-- > 0) {
|
||||||
const VALUE v = *++ptr;
|
const VALUE v = *++ptr;
|
||||||
if (OPTIMIZED_CMP(v, result, cmp_opt) > 0) {
|
if (OPTIMIZED_CMP(v, result, cmp_opt) > 0) {
|
||||||
@ -3237,7 +3237,7 @@ vm_opt_newarray_min(rb_num_t num, const VALUE *ptr)
|
|||||||
else {
|
else {
|
||||||
struct cmp_opt_data cmp_opt = { 0, 0 };
|
struct cmp_opt_data cmp_opt = { 0, 0 };
|
||||||
VALUE result = *ptr;
|
VALUE result = *ptr;
|
||||||
rb_num_t i = num - 1;
|
rb_snum_t i = num - 1;
|
||||||
while (i-- > 0) {
|
while (i-- > 0) {
|
||||||
const VALUE v = *++ptr;
|
const VALUE v = *++ptr;
|
||||||
if (OPTIMIZED_CMP(v, result, cmp_opt) < 0) {
|
if (OPTIMIZED_CMP(v, result, cmp_opt) < 0) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user