mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
struct.c: fix implicit conversions
* struct.c (struct_member_pos): revert r51080 to fix other implicit conversions but cast the return value to fix the previous implicit conversion. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51081 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
f91a556340
commit
e4984cf2d3
2 changed files with 10 additions and 4 deletions
|
@ -1,3 +1,9 @@
|
|||
Wed Jul 1 09:28:47 2015 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* struct.c (struct_member_pos): revert r51080 to fix other
|
||||
implicit conversions but cast the return value to fix the
|
||||
previous implicit conversion.
|
||||
|
||||
Wed Jul 1 08:47:24 2015 NARUSE, Yui <naruse@ruby-lang.org>
|
||||
|
||||
* struct.c (struct_member_pos): avoid implicit conversion loses
|
||||
|
|
8
struct.c
8
struct.c
|
@ -131,7 +131,7 @@ struct_member_pos(VALUE s, VALUE name)
|
|||
{
|
||||
VALUE back = struct_ivar_get(rb_obj_class(s), id_back_members);
|
||||
VALUE const * p;
|
||||
int j, mask;
|
||||
long j, mask;
|
||||
|
||||
if (UNLIKELY(NIL_P(back))) {
|
||||
rb_raise(rb_eTypeError, "uninitialized struct");
|
||||
|
@ -141,17 +141,17 @@ struct_member_pos(VALUE s, VALUE name)
|
|||
}
|
||||
|
||||
p = RARRAY_CONST_PTR(back);
|
||||
mask = RARRAY_LENINT(back);
|
||||
mask = RARRAY_LEN(back);
|
||||
|
||||
if (mask <= AREF_HASH_THRESHOLD) {
|
||||
if (UNLIKELY(RSTRUCT_LEN(s) != RARRAY_LEN(back))) {
|
||||
rb_raise(rb_eTypeError,
|
||||
"struct size differs (%d required %ld given)",
|
||||
"struct size differs (%ld required %ld given)",
|
||||
mask, RSTRUCT_LEN(s));
|
||||
}
|
||||
for (j = 0; j < mask; j++) {
|
||||
if (p[j] == name)
|
||||
return j;
|
||||
return (int)j;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue