From: Urvang Joshi Date: Mon, 17 Oct 2016 21:53:33 +0000 (-0700) Subject: Fix warnings reported by -Wshadow: Part4: main directory X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4145bf05ae1fae259593ef8f025795d77db5a4fc;p=libvpx Fix warnings reported by -Wshadow: Part4: main directory Now that all warnings are taken care of, add warning flag -Wshadow to configure. Note: Enabling this flag for C++ generates some useless warnings about some function parameters shadowing class member function names. So, only enabling this warning for C code. Cherry-picked from aomedia/master: b96cbc4 Change-Id: I3922dea2e6976b16519c4aa4d1bd395c198134f1 --- diff --git a/aomdec.c b/aomdec.c index d9f229da0..e88c81ffb 100644 --- a/aomdec.c +++ b/aomdec.c @@ -893,7 +893,7 @@ static int main_loop(int argc, const char **argv_) { if (single_file) { if (use_y4m) { - char buf[Y4M_BUFFER_SIZE] = { 0 }; + char y4m_buf[Y4M_BUFFER_SIZE] = { 0 }; size_t len = 0; if (img->fmt == AOM_IMG_FMT_I440 || img->fmt == AOM_IMG_FMT_I44016) { fprintf(stderr, "Cannot produce y4m output for 440 sampling.\n"); @@ -902,21 +902,22 @@ static int main_loop(int argc, const char **argv_) { if (frame_out == 1) { // Y4M file header len = y4m_write_file_header( - buf, sizeof(buf), aom_input_ctx.width, aom_input_ctx.height, - &aom_input_ctx.framerate, img->fmt, img->bit_depth); + y4m_buf, sizeof(y4m_buf), aom_input_ctx.width, + aom_input_ctx.height, &aom_input_ctx.framerate, img->fmt, + img->bit_depth); if (do_md5) { - MD5Update(&md5_ctx, (md5byte *)buf, (unsigned int)len); + MD5Update(&md5_ctx, (md5byte *)y4m_buf, (unsigned int)len); } else { - fputs(buf, outfile); + fputs(y4m_buf, outfile); } } // Y4M frame header - len = y4m_write_frame_header(buf, sizeof(buf)); + len = y4m_write_frame_header(y4m_buf, sizeof(y4m_buf)); if (do_md5) { - MD5Update(&md5_ctx, (md5byte *)buf, (unsigned int)len); + MD5Update(&md5_ctx, (md5byte *)y4m_buf, (unsigned int)len); } else { - fputs(buf, outfile); + fputs(y4m_buf, outfile); } } else { if (frame_out == 1) { diff --git a/aomenc.c b/aomenc.c index 63ef753ad..3f9a87d0e 100644 --- a/aomenc.c +++ b/aomenc.c @@ -1753,13 +1753,11 @@ static void test_decode(struct stream_state *stream, /* Get the internal reference frame */ if (strcmp(codec->name, "vp8") == 0) { struct aom_ref_frame ref_enc, ref_dec; - int width, height; - - width = (stream->config.cfg.g_w + 15) & ~15; - height = (stream->config.cfg.g_h + 15) & ~15; - aom_img_alloc(&ref_enc.img, AOM_IMG_FMT_I420, width, height, 1); + const unsigned int frame_width = (stream->config.cfg.g_w + 15) & ~15; + const unsigned int frame_height = (stream->config.cfg.g_h + 15) & ~15; + aom_img_alloc(&ref_enc.img, AOM_IMG_FMT_I420, frame_width, frame_height, 1); enc_img = ref_enc.img; - aom_img_alloc(&ref_dec.img, AOM_IMG_FMT_I420, width, height, 1); + aom_img_alloc(&ref_dec.img, AOM_IMG_FMT_I420, frame_width, frame_height, 1); dec_img = ref_dec.img; ref_enc.frame_type = AOM_LAST_FRAME; @@ -2131,10 +2129,10 @@ int main(int argc, const char **argv_) { } else { const int64_t input_pos = ftello(input.file); const int64_t input_pos_lagged = input_pos - lagged_count; - const int64_t limit = input.length; + const int64_t input_limit = input.length; rate = cx_time ? input_pos_lagged * (int64_t)1000000 / cx_time : 0; - remaining = limit - input_pos + lagged_count; + remaining = input_limit - input_pos + lagged_count; } average_rate = diff --git a/av1/encoder/rdopt.c b/av1/encoder/rdopt.c index 2f9c42aa7..8399a850a 100644 --- a/av1/encoder/rdopt.c +++ b/av1/encoder/rdopt.c @@ -9381,7 +9381,7 @@ void av1_rd_pick_inter_mode_sb(const AV1_COMP *cpi, TileDataEnc *tile_data, int best_rate_nocoef; #endif int64_t distortion2 = 0, distortion_y = 0, dummy_rd = best_rd, this_rd; - int skippable = 0, rate_overhead = 0; + int skippable = 0; TX_SIZE best_tx_size, uv_tx; TX_TYPE best_tx_type; PALETTE_MODE_INFO palette_mode_info; @@ -9389,6 +9389,7 @@ void av1_rd_pick_inter_mode_sb(const AV1_COMP *cpi, TileDataEnc *tile_data, x->palette_buffer->best_palette_color_map; uint8_t *const color_map = xd->plane[0].color_index_map; + rate_overhead = 0; mbmi->mode = DC_PRED; mbmi->uv_mode = DC_PRED; mbmi->ref_frame[0] = INTRA_FRAME; @@ -9551,7 +9552,6 @@ PALETTE_EXIT: nearmv[1] = frame_mv[NEARMV][refs[1]]; } #else - int i; int ref_set = (mbmi_ext->ref_mv_count[rf_type] >= 2) ? AOMMIN(2, mbmi_ext->ref_mv_count[rf_type] - 2) : INT_MAX; diff --git a/configure b/configure index d911d9a9a..53ba10e37 100755 --- a/configure +++ b/configure @@ -611,6 +611,10 @@ process_toolchain() { check_add_cflags -Wuninitialized check_add_cflags -Wunused-variable check_add_cflags -Wsign-compare + # Enabling the following warning for C++ generates some useless warnings + # about some function parameters shadowing class member function names. + # So, only enable this warning for C code. + check_cflags "-Wshadow" && add_cflags_only "-Wshadow" case ${CC} in *clang*) ;; *) check_add_cflags -Wunused-but-set-variable ;;