From e4984cf2d36880e28e95919e02073f9aaae5f036 Mon Sep 17 00:00:00 2001 From: nobu Date: Wed, 1 Jul 2015 00:28:49 +0000 Subject: [PATCH] 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 --- ChangeLog | 6 ++++++ struct.c | 8 ++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index e9821f1290..cc0634f792 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Wed Jul 1 09:28:47 2015 Nobuyoshi Nakada + + * 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 * struct.c (struct_member_pos): avoid implicit conversion loses diff --git a/struct.c b/struct.c index 17c4643b72..c7ae830337 100644 --- a/struct.c +++ b/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; }