diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-07-01 00:28:49 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-07-01 00:28:49 +0000 |
commit | e4984cf2d36880e28e95919e02073f9aaae5f036 (patch) | |
tree | 10f5bbc95546a00e2a4d3510c496573aa9737904 | |
parent | f91a5563400156bbacc6373a2dea0dcaf182a433 (diff) |
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
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | struct.c | 8 |
2 files changed, 10 insertions, 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 @@ -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; } |