Skip to content

Commit

Permalink
Fix Clang -Wunreachable-code-aggressive warnings
Browse files Browse the repository at this point in the history
Based on the change in libaom:
fe36011455 Fix Clang -Wunreachable-code-aggressive warnings

Clang's -Wunreachable-code-aggressive flag enables several warning flags
such as -Wunreachable-code-break and -Wunreachable-code-return. Chrome's
build system enables -Wunreachable-code-aggressive (in
build/config/compiler/BUILD.gn), so it would be good if libvpx could be
compiled without -Wunreachable-code-aggressive warnings.

This requires the VPX_NO_RETURN macro be defined correctly for all the
compilers we support, otherwise some compilers may warn about missing
return statements after a die() or fatal() call (which does not return).

Change-Id: I0c069133af45a7a61759538b6d74c681ea087dcd
  • Loading branch information
jzern committed Jun 28, 2023
1 parent 44d6cac commit 3ecba39
Show file tree
Hide file tree
Showing 13 changed files with 25 additions and 41 deletions.
3 changes: 0 additions & 3 deletions args.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@ unsigned int arg_parse_uint(const struct arg *arg) {
}

die("Option %s: Invalid character '%c'\n", arg->name, *endptr);
return 0;
}

int arg_parse_int(const struct arg *arg) {
Expand All @@ -152,7 +151,6 @@ int arg_parse_int(const struct arg *arg) {
}

die("Option %s: Invalid character '%c'\n", arg->name, *endptr);
return 0;
}

struct vpx_rational {
Expand Down Expand Up @@ -209,7 +207,6 @@ int arg_parse_enum(const struct arg *arg) {
if (!strcmp(arg->val, listptr->name)) return listptr->val;

die("Option %s: Invalid value '%s'\n", arg->name, arg->val);
return 0;
}

int arg_parse_enum_or_int(const struct arg *arg) {
Expand Down
2 changes: 1 addition & 1 deletion configure
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,7 @@ process_toolchain() {
check_add_cflags -Wmissing-prototypes
check_add_cflags -Wshadow
check_add_cflags -Wuninitialized
check_add_cflags -Wunreachable-code-loop-increment
check_add_cflags -Wunreachable-code-aggressive
check_add_cflags -Wunused
check_add_cflags -Wextra
# check_add_cflags also adds to cxxflags. gtest does not do well with
Expand Down
1 change: 0 additions & 1 deletion examples/vp9_spatial_svc_encoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,6 @@ static void parse_command_line(int argc, const char **argv_,
break;
default:
die("Error: Invalid bit depth selected (%d)\n", enc_cfg->g_bit_depth);
break;
}
#endif // CONFIG_VP9_HIGHBITDEPTH
} else if (arg_match(&arg, &dropframe_thresh_arg, argi)) {
Expand Down
2 changes: 1 addition & 1 deletion test/partial_idct_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class PartialIDctTest : public ::testing::TestWithParam<PartialInvTxfmParam> {
case TX_8X8: size_ = 8; break;
case TX_16X16: size_ = 16; break;
case TX_32X32: size_ = 32; break;
default: FAIL() << "Wrong Size!"; break;
default: FAIL() << "Wrong Size!";
}

// Randomize stride_ to a value less than or equal to 1024
Expand Down
2 changes: 1 addition & 1 deletion test/vp9_ratectrl_rtc_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ class RcInterfaceSvcTest
rc_cfg_.layer_target_bitrate[4] = 0;
rc_cfg_.layer_target_bitrate[5] = 0;
ASSERT_TRUE(rc_api_->UpdateRateControl(rc_cfg_));
} else if (0 && video->frame() == 280) {
} else if (/*DISABLES CODE*/ (0) && video->frame() == 280) {
// TODO(marpan): Re-enable this going back up when issue is fixed.
// Go back up to 3 spatial layers.
// Update the encoder config: use the original bitrates.
Expand Down
10 changes: 5 additions & 5 deletions tools_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ static void highbd_img_upshift(vpx_image_t *dst, vpx_image_t *src,
case VPX_IMG_FMT_I42216:
case VPX_IMG_FMT_I44416:
case VPX_IMG_FMT_I44016: break;
default: fatal("Unsupported image conversion"); break;
default: fatal("Unsupported image conversion");
}
for (plane = 0; plane < 3; plane++) {
int w = src->d_w;
Expand Down Expand Up @@ -411,7 +411,7 @@ static void lowbd_img_upshift(vpx_image_t *dst, vpx_image_t *src,
case VPX_IMG_FMT_I422:
case VPX_IMG_FMT_I444:
case VPX_IMG_FMT_I440: break;
default: fatal("Unsupported image conversion"); break;
default: fatal("Unsupported image conversion");
}
for (plane = 0; plane < 3; plane++) {
int w = src->d_w;
Expand Down Expand Up @@ -452,7 +452,7 @@ void vpx_img_truncate_16_to_8(vpx_image_t *dst, vpx_image_t *src) {
case VPX_IMG_FMT_I422:
case VPX_IMG_FMT_I444:
case VPX_IMG_FMT_I440: break;
default: fatal("Unsupported image conversion"); break;
default: fatal("Unsupported image conversion");
}
for (plane = 0; plane < 3; plane++) {
int w = src->d_w;
Expand Down Expand Up @@ -487,7 +487,7 @@ static void highbd_img_downshift(vpx_image_t *dst, vpx_image_t *src,
case VPX_IMG_FMT_I42216:
case VPX_IMG_FMT_I44416:
case VPX_IMG_FMT_I44016: break;
default: fatal("Unsupported image conversion"); break;
default: fatal("Unsupported image conversion");
}
for (plane = 0; plane < 3; plane++) {
int w = src->d_w;
Expand Down Expand Up @@ -521,7 +521,7 @@ static void lowbd_img_downshift(vpx_image_t *dst, vpx_image_t *src,
case VPX_IMG_FMT_I422:
case VPX_IMG_FMT_I444:
case VPX_IMG_FMT_I440: break;
default: fatal("Unsupported image conversion"); break;
default: fatal("Unsupported image conversion");
}
for (plane = 0; plane < 3; plane++) {
int w = src->d_w;
Expand Down
2 changes: 1 addition & 1 deletion vp8/decoder/decodeframe.c
Original file line number Diff line number Diff line change
Expand Up @@ -1167,7 +1167,7 @@ int vp8_decode_frame(VP8D_COMP *pbi) {
if (pbi->ec_active && xd->corrupted) pc->refresh_last_frame = 1;
#endif

if (0) {
if (/*DISABLES CODE*/ (0)) {
FILE *z = fopen("decodestats.stt", "a");
fprintf(z, "%6d F:%d,G:%d,A:%d,L:%d,Q:%d\n", pc->current_video_frame,
pc->frame_type, pc->refresh_golden_frame, pc->refresh_alt_ref_frame,
Expand Down
10 changes: 5 additions & 5 deletions vp8/encoder/firstpass.c
Original file line number Diff line number Diff line change
Expand Up @@ -822,7 +822,7 @@ void vp8_first_pass(VP8_COMP *cpi) {
}

/* use this to see what the first pass reconstruction looks like */
if (0) {
if (/*DISABLES CODE*/ (0)) {
char filename[512];
FILE *recon_file;
sprintf(filename, "enc%04d.yuv", (int)cm->current_video_frame);
Expand Down Expand Up @@ -1038,7 +1038,7 @@ static int estimate_cq(VP8_COMP *cpi, FIRSTPASS_STATS *fpstats,
double clip_iifactor;
int overhead_bits_per_mb;

if (0) {
if (/*DISABLES CODE*/ (0)) {
FILE *f = fopen("epmp.stt", "a");
fprintf(f, "%10.2f\n", err_per_mb);
fclose(f);
Expand Down Expand Up @@ -1230,7 +1230,7 @@ static int estimate_kf_group_q(VP8_COMP *cpi, double section_err,
Q++;
}

if (0) {
if (/*DISABLES CODE*/ (0)) {
FILE *f = fopen("estkf_q.stt", "a");
fprintf(f, "%8d %8d %8d %8.2f %8.3f %8.2f %8.3f %8.3f %8.3f %8d\n",
cpi->common.current_video_frame, bits_per_mb_at_this_q,
Expand Down Expand Up @@ -3047,7 +3047,7 @@ static void find_next_key_frame(VP8_COMP *cpi, FIRSTPASS_STATS *this_frame) {
(int)((projected_bits_perframe - av_bits_per_frame) *
cpi->twopass.frames_to_key));

if (0) {
if (/*DISABLES CODE*/ (0)) {
FILE *f = fopen("Subsamle.stt", "a");
fprintf(f, " %8d %8d %8d %8d %12.0f %8d %8d %8d\n",
cpi->common.current_video_frame, kf_q, cpi->common.horiz_scale,
Expand Down Expand Up @@ -3121,7 +3121,7 @@ static void find_next_key_frame(VP8_COMP *cpi, FIRSTPASS_STATS *this_frame) {
kf_q = estimate_kf_group_q(cpi, err_per_frame * effective_size_ratio,
(int)bits_per_frame, group_iiratio);

if (0) {
if (/*DISABLES CODE*/ (0)) {
FILE *f = fopen("Subsamle.stt", "a");
fprintf(
f, "******** %8d %8d %8d %12.0f %8d %8d %8d\n", kf_q,
Expand Down
1 change: 0 additions & 1 deletion vp9/encoder/vp9_ext_ratectrl.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ static int extrc_get_frame_type(FRAME_UPDATE_TYPE update_type) {
default:
fprintf(stderr, "Unsupported update_type %d\n", update_type);
abort();
return 1;
}
}

Expand Down
5 changes: 1 addition & 4 deletions vp9/encoder/vp9_firstpass.c
Original file line number Diff line number Diff line change
Expand Up @@ -364,23 +364,20 @@ static vpx_variance_fn_t highbd_get_block_variance_fn(BLOCK_SIZE bsize,
case BLOCK_8X16: return vpx_highbd_8_mse8x16;
default: return vpx_highbd_8_mse16x16;
}
break;
case 10:
switch (bsize) {
case BLOCK_8X8: return vpx_highbd_10_mse8x8;
case BLOCK_16X8: return vpx_highbd_10_mse16x8;
case BLOCK_8X16: return vpx_highbd_10_mse8x16;
default: return vpx_highbd_10_mse16x16;
}
break;
case 12:
switch (bsize) {
case BLOCK_8X8: return vpx_highbd_12_mse8x8;
case BLOCK_16X8: return vpx_highbd_12_mse16x8;
case BLOCK_8X16: return vpx_highbd_12_mse8x16;
default: return vpx_highbd_12_mse16x16;
}
break;
}
}

Expand Down Expand Up @@ -1508,7 +1505,7 @@ void vp9_first_pass(VP9_COMP *cpi, const struct lookahead_entry *source) {
}

// Use this to see what the first pass reconstruction looks like.
if (0) {
if (/*DISABLES CODE*/ (0)) {
char filename[512];
FILE *recon_file;
snprintf(filename, sizeof(filename), "enc%04d.yuv",
Expand Down
25 changes: 9 additions & 16 deletions vp9/encoder/vp9_mbgraph.c
Original file line number Diff line number Diff line change
Expand Up @@ -333,23 +333,16 @@ static void separate_arf_mbs(VP9_COMP *cpi) {
}
}

// Only bother with segmentation if over 10% of the MBs in static segment
// if ( ncnt[1] && (ncnt[0] / ncnt[1] < 10) )
if (1) {
// Note % of blocks that are marked as static
if (cm->MBs)
cpi->static_mb_pct = (ncnt[1] * 100) / (cm->mi_rows * cm->mi_cols);

// This error case should not be reachable as this function should
// never be called with the common data structure uninitialized.
else
cpi->static_mb_pct = 0;

vp9_enable_segmentation(&cm->seg);
} else {
// Note % of blocks that are marked as static
if (cm->MBs)
cpi->static_mb_pct = (ncnt[1] * 100) / (cm->mi_rows * cm->mi_cols);

// This error case should not be reachable as this function should
// never be called with the common data structure uninitialized.
else
cpi->static_mb_pct = 0;
vp9_disable_segmentation(&cm->seg);
}

vp9_enable_segmentation(&cm->seg);

// Free localy allocated storage
vpx_free(arf_not_zz);
Expand Down
1 change: 0 additions & 1 deletion vp9/simple_encode.cc
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ get_frame_type_from_update_type(FRAME_UPDATE_TYPE update_type) {
default:
fprintf(stderr, "Unsupported update_type %d\n", update_type);
abort();
return kFrameTypeInter;
}
}

Expand Down
2 changes: 1 addition & 1 deletion vpxdec.c
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ static void generate_filename(const char *pattern, char *out, size_t q_len,
case '7': snprintf(q, q_len - 1, "%07d", frame_in); break;
case '8': snprintf(q, q_len - 1, "%08d", frame_in); break;
case '9': snprintf(q, q_len - 1, "%09d", frame_in); break;
default: die("Unrecognized pattern %%%c\n", p[1]); break;
default: die("Unrecognized pattern %%%c\n", p[1]);
}

pat_len = strlen(q);
Expand Down

0 comments on commit 3ecba39

Please sign in to comment.