ruby-changes:48091
From: nobu <ko1@a...>
Date: Wed, 18 Oct 2017 13:35:32 +0900 (JST)
Subject: [ruby-changes:48091] nobu:r60204 (trunk): Get rid of shadowing local variables
nobu 2017-10-18 13:35:25 +0900 (Wed, 18 Oct 2017) New Revision: 60204 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=60204 Log: Get rid of shadowing local variables Modified files: trunk/bignum.c trunk/configure.ac trunk/dir.c trunk/enumerator.c trunk/file.c trunk/gc.c trunk/io.c Index: enumerator.c =================================================================== --- enumerator.c (revision 60203) +++ enumerator.c (revision 60204) @@ -1119,11 +1119,11 @@ enumerator_size(VALUE obj) https://github.com/ruby/ruby/blob/trunk/enumerator.c#L1119 for (i = 0; i < RARRAY_LEN(e->procs); i++) { VALUE proc = RARRAY_AREF(e->procs, i); struct proc_entry *entry = proc_entry_ptr(proc); - lazyenum_size_func *size = entry->fn->size; - if (!size) { + lazyenum_size_func *size_fn = entry->fn->size; + if (!size_fn) { return Qnil; } - receiver = (*size)(proc, receiver); + receiver = (*size_fn)(proc, receiver); } return receiver; } Index: io.c =================================================================== --- io.c (revision 60203) +++ io.c (revision 60204) @@ -3575,9 +3575,9 @@ io_getc(rb_io_t *fptr, rb_encoding *enc) https://github.com/ruby/ruby/blob/trunk/io.c#L3575 VALUE str; if (NEED_READCONV(fptr)) { - VALUE str = Qnil; rb_encoding *read_enc = io_read_encoding(fptr); + str = Qnil; SET_BINARY_MODE(fptr); make_readconv(fptr, 0); Index: dir.c =================================================================== --- dir.c (revision 60203) +++ dir.c (revision 60204) @@ -2154,8 +2154,8 @@ glob_helper( https://github.com/ruby/ruby/blob/trunk/dir.c#L2154 } #if USE_NAME_ON_FS == USE_NAME_ON_FS_REAL_BASENAME if ((*cur)->type == ALPHA) { - long base = pathlen + (dirsep != 0); - buf = replace_real_basename(buf, base, enc, IF_NORMALIZE_UTF8PATH(1)+0, + buf = replace_real_basename(buf, pathlen + (dirsep != 0), enc, + IF_NORMALIZE_UTF8PATH(1)+0, flags, &new_pathtype); if (!buf) break; } Index: bignum.c =================================================================== --- bignum.c (revision 60203) +++ bignum.c (revision 60204) @@ -903,8 +903,6 @@ bary_pack(int sign, BDIGIT *ds, size_t n https://github.com/ruby/ruby/blob/trunk/bignum.c#L903 } if ((flags & INTEGER_PACK_2COMP) && (sign < 0 && numwords != 0)) { - unsigned char *buf; - int word_num_partialbits; size_t word_num_fullbytes; Index: gc.c =================================================================== --- gc.c (revision 60203) +++ gc.c (revision 60204) @@ -5202,11 +5202,13 @@ gc_verify_heap_page(rb_objspace_t *objsp https://github.com/ruby/ruby/blob/trunk/gc.c#L5202 int zombie_objects = 0; for (i=0; i<page->total_slots; i++) { - VALUE obj = (VALUE)&page->start[i]; - if (RBASIC(obj) == 0) free_objects++; - if (BUILTIN_TYPE(obj) == T_ZOMBIE) zombie_objects++; - if (RVALUE_PAGE_UNCOLLECTIBLE(page, obj) && RVALUE_PAGE_WB_UNPROTECTED(page, obj)) has_remembered_shady = TRUE; - if (RVALUE_PAGE_MARKING(page, obj)) { + VALUE val = (VALUE)&page->start[i]; + if (RBASIC(val) == 0) free_objects++; + if (BUILTIN_TYPE(val) == T_ZOMBIE) zombie_objects++; + if (RVALUE_PAGE_UNCOLLECTIBLE(page, val) && RVALUE_PAGE_WB_UNPROTECTED(page, val)) { + has_remembered_shady = TRUE; + } + if (RVALUE_PAGE_MARKING(page, val)) { has_remembered_old = TRUE; rememberd_old_objects++; } @@ -5216,9 +5218,9 @@ gc_verify_heap_page(rb_objspace_t *objsp https://github.com/ruby/ruby/blob/trunk/gc.c#L5218 page->flags.has_remembered_objects == FALSE && has_remembered_old == TRUE) { for (i=0; i<page->total_slots; i++) { - VALUE obj = (VALUE)&page->start[i]; - if (RVALUE_PAGE_MARKING(page, obj)) { - fprintf(stderr, "marking -> %s\n", obj_info(obj)); + VALUE val = (VALUE)&page->start[i]; + if (RVALUE_PAGE_MARKING(page, val)) { + fprintf(stderr, "marking -> %s\n", obj_info(val)); } } rb_bug("page %p's has_remembered_objects should be false, but there are remembered old objects (%d). %s", Index: file.c =================================================================== --- file.c (revision 60203) +++ file.c (revision 60204) @@ -3946,11 +3946,11 @@ realpath_rec(long *prefixlenp, VALUE *re https://github.com/ruby/ruby/blob/trunk/file.c#L3946 link_names = skipprefixroot(link_prefix, link_prefix + RSTRING_LEN(link), rb_enc_get(link)); link_prefixlen = link_names - link_prefix; if (link_prefixlen > 0) { - rb_encoding *enc, *linkenc = rb_enc_get(link); + rb_encoding *tmpenc, *linkenc = rb_enc_get(link); link_orig = link; link = rb_str_subseq(link, 0, link_prefixlen); - enc = rb_enc_check(*resolvedp, link); - if (enc != linkenc) link = rb_str_conv_enc(link, linkenc, enc); + tmpenc = rb_enc_check(*resolvedp, link); + if (tmpenc != linkenc) link = rb_str_conv_enc(link, linkenc, tmpenc); *resolvedp = link; *prefixlenp = link_prefixlen; } Index: configure.ac =================================================================== --- configure.ac (revision 60203) +++ configure.ac (revision 60204) @@ -876,10 +876,13 @@ AS_IF([test "$GCC:${warnflags+set}:no" = https://github.com/ruby/ruby/blob/trunk/configure.ac#L876 -Werror=implicit-function-declaration \ -Werror=division-by-zero \ -Werror=deprecated-declarations \ + -Werror=misleading-indentation \ -Wno-packed-bitfield-compat \ -Wsuggest-attribute=noreturn \ -Wsuggest-attribute=format \ -Wimplicit-fallthrough=0 \ + -Werror=duplicated-cond \ + -Werror=restrict \ $extra_warning \ ; do AS_IF([test "$particular_werror_flags" != yes], [ -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/