Skip to content

Commit 469142d

Browse files
Fix a gcc warning in rb_git_repo_merge_bases.
1 parent d5a703e commit 469142d

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

ext/rugged/rugged_repo.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -645,19 +645,21 @@ static VALUE rb_git_repo_merge_base(VALUE self, VALUE rb_args)
645645
*/
646646
static VALUE rb_git_repo_merge_bases(VALUE self, VALUE rb_args)
647647
{
648-
int error = GIT_OK, i;
648+
int error = GIT_OK;
649+
size_t i, len = (size_t)RARRAY_LEN(rb_args);
649650
git_repository *repo;
650651
git_oidarray bases = {NULL, 0};
651-
git_oid *input_array = xmalloc(sizeof(git_oid) * RARRAY_LEN(rb_args));
652-
int len = (int)RARRAY_LEN(rb_args);
652+
git_oid *input_array;
653653

654654
VALUE rb_bases;
655655

656656
if (len < 2)
657-
rb_raise(rb_eArgError, "wrong number of arguments (%d for 2+)", len);
657+
rb_raise(rb_eArgError, "wrong number of arguments (%ld for 2+)", RARRAY_LEN(rb_args));
658658

659659
Data_Get_Struct(self, git_repository, repo);
660660

661+
input_array = xmalloc(sizeof(git_oid) * len);
662+
661663
for (i = 0; !error && i < len; ++i) {
662664
error = rugged_oid_get(&input_array[i], repo, rb_ary_entry(rb_args, i));
663665
}

0 commit comments

Comments
 (0)