@@ -640,9 +640,9 @@ const char *dvb_cmd_name(int cmd)
{
if (cmd >= 0 && cmd < ARRAY_SIZE(dvb_v5_name))
return dvb_v5_name[cmd];
- else if (cmd >= DTV_USER_COMMAND_START && cmd <= DTV_MAX_USER_COMMAND)
+ if (cmd >= DTV_USER_COMMAND_START && cmd <= DTV_MAX_USER_COMMAND)
return dvb_user_name[cmd - DTV_USER_COMMAND_START];
- else if (cmd >= DTV_STAT_COMMAND_START && cmd <= DTV_MAX_STAT_COMMAND)
+ if (cmd >= DTV_STAT_COMMAND_START && cmd <= DTV_MAX_STAT_COMMAND)
return dvb_stat_name[cmd - DTV_STAT_COMMAND_START];
return NULL;
}
@@ -651,7 +651,6 @@ const char *const *dvb_attr_names(int cmd)
{
if (cmd >= 0 && cmd < DTV_MAX_COMMAND)
return dvb_v5_attr_names[cmd];
-
if (cmd >= DTV_USER_COMMAND_START && cmd <= DTV_MAX_USER_COMMAND)
return dvb_user_attr_names[cmd - DTV_USER_COMMAND_START];
return NULL;
@@ -1169,10 +1168,11 @@ static enum dvb_quality cnr_arr_to_qual(uint32_t modulation,
if (modulation == arr[i].modulation) {
if (cnr < arr[i].cnr_ok)
return DVB_QUAL_POOR;
- else if (cnr < arr[i].cnr_good)
+
+ if (cnr < arr[i].cnr_good)
return DVB_QUAL_OK;
- else
- return DVB_QUAL_GOOD;
+
+ return DVB_QUAL_GOOD;
}
}
@@ -1367,10 +1367,11 @@ enum dvb_quality dvb_fe_retrieve_quality(struct dvb_v5_fe_parms *p,
if (ber > 1e-3) /* FIXME: good enough???? */
return DVB_QUAL_POOR;
+
if (ber <= 2e-4) /* BER = 10^-11 at TS */
return DVB_QUAL_GOOD;
- else
- qual = DVB_QUAL_OK; /* OK or good */
+
+ qual = DVB_QUAL_OK; /* OK or good */
}
cnr = dvb_fe_retrieve_stats_layer(&parms->p, DTV_STAT_CNR, layer);
@@ -1665,15 +1666,15 @@ static int __dvb_fe_snprintf_eng(char *buf, int len, float val, int metric)
if (signal > 0)
return snprintf(buf, len, " %.*fx10^%d", digits - 1,
val, exp);
- else
- return snprintf(buf, len, " -%.*fx10^%d", digits - 1,
+
+ return snprintf(buf, len, " -%.*fx10^%d", digits - 1,
val, exp);
- } else {
- if (signal > 0)
- return snprintf(buf, len, " %.*f", digits - 1, val);
- else
- return snprintf(buf, len, " -%.*f", digits - 1, val);
}
+
+ if (signal > 0)
+ return snprintf(buf, len, " %.*f", digits - 1, val);
+
+ return snprintf(buf, len, " -%.*f", digits - 1, val);
}
int dvb_fe_snprintf_eng(char *buf, int len, float val)
@@ -306,7 +306,7 @@ static bool rds_add_tmc_af(struct rds_private_state *priv_state)
}
/* mapped frequency pair */
- else if (variant == 7) {
+ if (variant == 7) {
/* check if there's already a frequency mapped to the new tuning
* frequency, update the mapped frequency in this case */
for (int i = 0; i < afi->mapped_af_size; i++) {
@@ -653,7 +653,7 @@ huffmanDecoderY(int *C, int *pIn, struct comp_info *cinfo)
if (skip == -1) {
break;
- } else if (skip == 0) {
+ } if (skip == 0) {
C[i++] = coeff;
} else if (skip == 16) {
k = 16;
@@ -697,7 +697,7 @@ huffmanDecoderUV(int *C, int *pIn, struct comp_info *cinfo)
if (skip == -1) {
break;
- } else if (skip == 0) {
+ } if (skip == 0) {
C[i++] = coeff;
} else if (skip == 16) {
k = 16;
@@ -1327,8 +1327,8 @@ decompress420NoMMXOV518(unsigned char *pIn,
/* Did we decode enough? */
if (cinfo->bytes >= cinfo->rawLen - (897 + 64))
return 0;
- else
- return 1;
+
+ return 1;
}
/* Get quantization tables from input
@@ -110,8 +110,8 @@ static int fun_C(int *bitfill, int gkw)
if (gkw == 0xfe) {
if (nbits(bitfill, 1) == 0)
return 7;
- else
- return -8;
+
+ return -8;
}
if (gkw != 0xff)
@@ -393,7 +393,7 @@ static void process_Huffman_data_unit(struct jdec_private *priv, int component)
if (size_val == 0) { /* RLE */
if (count_0 == 0)
break; /* EOB found, go out */
- else if (count_0 == 0xF)
+ if (count_0 == 0xF)
j += 16; /* skip 16 zeros */
} else {
j += count_0; /* skip count_0 zeroes */
@@ -224,11 +224,11 @@ static int arc_initiate_rx(struct node *node, unsigned me, unsigned la, bool int
announce("The device supports ARC but is not ready to initiate.");
return 0;
}
- else {
- warn("Device responded Feature Abort with unexpected abort reason. Assuming no ARC support.\n");
- unsupported = true;
- }
+
+ warn("Device responded Feature Abort with unexpected abort reason. Assuming no ARC support.\n");
+ unsupported = true;
}
+
if (unsupported) {
fail_on_test_v2(node->remote[la].cec_version, node->remote[la].source_has_arc_rx);
return OK_NOT_SUPPORTED;
@@ -166,8 +166,8 @@ static int one_touch_play_view_on_wakeup(struct node *node, unsigned me, unsigne
if (interactive)
return 0;
- else
- return OK_PRESUMED;
+
+ return OK_PRESUMED;
}
static int one_touch_play_image_view_on_wakeup(struct node *node, unsigned me, unsigned la, bool interactive)
@@ -203,8 +203,8 @@ static int one_touch_play_view_on_change(struct node *node, unsigned me, unsigne
if (interactive)
return 0;
- else
- return OK_PRESUMED;
+
+ return OK_PRESUMED;
}
static int one_touch_play_image_view_on_change(struct node *node, unsigned me, unsigned la, bool interactive)
@@ -352,9 +352,9 @@ static int osd_string_set_default(struct node *node, unsigned me, unsigned la, b
(node->remote[la].dev_features & CEC_OP_FEAT_DEV_HAS_SET_OSD_STRING));
if (unrecognized_op(&msg))
return OK_NOT_SUPPORTED;
- else if (refused(&msg))
+ if (refused(&msg))
return OK_REFUSED;
- else if (cec_msg_status_is_abort(&msg)) {
+ if (cec_msg_status_is_abort(&msg)) {
warn("The device is in an unsuitable state or cannot display the complete message.\n");
unsuitable = true;
}
@@ -402,8 +402,8 @@ static int osd_string_set_until_clear(struct node *node, unsigned me, unsigned l
if (interactive)
return 0;
- else
- return OK_PRESUMED;
+
+ return OK_PRESUMED;
}
static int osd_string_invalid(struct node *node, unsigned me, unsigned la, bool interactive)
@@ -480,8 +480,8 @@ static int routing_control_active_source(struct node *node, unsigned me, unsigne
if (interactive)
return 0;
- else
- return OK_PRESUMED;
+
+ return OK_PRESUMED;
}
static int routing_control_req_active_source(struct node *node, unsigned me, unsigned la, bool interactive)
@@ -529,9 +529,8 @@ static int routing_control_set_stream_path(struct node *node, unsigned me, unsig
if (interactive || node->remote[la].cec_version >= CEC_OP_CEC_VERSION_2_0)
return 0;
- else
- return OK_PRESUMED;
- return 0;
+
+ return OK_PRESUMED;
}
static struct remote_subtest routing_control_subtests[] = {
@@ -900,10 +899,10 @@ static int tuner_ctl_test(struct node *node, unsigned me, unsigned la, bool inte
if (abort_reason(&msg) == CEC_OP_ABORT_REFUSED) {
warn("Tuner step increment does not wrap.\n");
break;
- } else {
- warn("Tuner at end of service list did not receive feature abort refused.\n");
- break;
}
+
+ warn("Tuner at end of service list did not receive feature abort refused.\n");
+ break;
}
cec_msg_init(&msg, me, la);
cec_msg_give_tuner_device_status(&msg, true, CEC_OP_STATUS_REQ_ONCE);
@@ -1050,8 +1049,8 @@ static int one_touch_rec_off(struct node *node, unsigned me, unsigned la, bool i
return OK_PRESUMED;
if (timed_out(&msg))
return OK_PRESUMED;
- else
- return 0;
+
+ return 0;
}
static int one_touch_rec_status(struct node *node, unsigned me, unsigned la, bool interactive)
@@ -1332,8 +1331,8 @@ static int cdc_hec_discover(struct node *node, unsigned me, unsigned la, bool pr
if (msg.msg[1] == CEC_MSG_FEATURE_ABORT) {
if (from == la)
return fail("Device replied Feature Abort to broadcast message\n");
- else
- warn("Device %d replied Feature Abort to broadcast message\n", cec_msg_initiator(&msg));
+
+ warn("Device %d replied Feature Abort to broadcast message\n", cec_msg_initiator(&msg));
}
if (msg.msg[1] != CEC_MSG_CDC_MESSAGE)
continue;
@@ -227,7 +227,7 @@ std::string audio_format_id_code2s(__u8 audio_format_id, __u8 audio_format_code)
{
if (audio_format_id == 0)
return audio_format_code2s(audio_format_code);
- else if (audio_format_id == 1)
+ if (audio_format_id == 1)
return extension_type_code2s(audio_format_code);
return "Invalid";
}
@@ -692,8 +692,8 @@ static void processMsg(struct node *node, struct cec_msg &msg, unsigned me)
signalize that we support SAC. */
if (cec_has_tv(1 << me))
return;
- else
- break;
+
+ break;
}
cec_ops_set_system_audio_mode(&msg, &system_audio_status);
if (system_audio_status == CEC_OP_SYS_AUD_STATUS_ON)
@@ -527,8 +527,8 @@ error_t parse_keymap(char *fname, struct keymap **keymap, bool verbose)
if (len >= 5 && strcasecmp(fname + len - 5, ".toml") == 0)
return parse_toml_keymap(fname, keymap, verbose);
- else
- return parse_plain_keymap(fname, keymap, verbose);
+
+ return parse_plain_keymap(fname, keymap, verbose);
}
int keymap_param(struct keymap *map, const char *name, int fallback)
@@ -1697,7 +1697,7 @@ int toml_rtots(const char* src_, toml_timestamp_t* ret)
for (i = 0; i < 10; i++, p++) {
int xx = *p;
if (xx == '-') {
- if (i == 4 || i == 7) continue; else return -1;
+ if (i == 4 || i == 7) continue; return -1;
}
if (! ('0' <= xx && xx <= '9')) return -1;
val = val * 10 + (xx - '0');
@@ -1724,7 +1724,7 @@ int toml_rtots(const char* src_, toml_timestamp_t* ret)
for (i = 0; i < 8; i++, p++) {
int xx = *p;
if (xx == ':') {
- if (i == 2 || i == 5) continue; else return -1;
+ if (i == 2 || i == 5) continue; return -1;
}
if (! ('0' <= xx && xx <= '9')) return -1;
val = val * 10 + (xx - '0');
@@ -88,7 +88,7 @@ void rle_decompress(__u8 *b, unsigned size, unsigned rle_size, unsigned bpl)
i += 4;
next_line = dst + bpl / 4;
continue;
- } else if (v == magic_x) {
+ } if (v == magic_x) {
v = *++p;
n = ntohl(*++p);
i += 8;
@@ -1159,9 +1159,8 @@ int lirc_receive(struct arguments *args, int fd, unsigned features)
// is meaningless, maybe fix the kernel?
if (leading_space && msg == LIRC_MODE2_SPACE)
continue;
- else
- leading_space = false;
+ leading_space = false;
if (args->oneshot &&
(msg == LIRC_MODE2_TIMEOUT ||
(msg == LIRC_MODE2_SPACE && val > 19000))) {
@@ -266,7 +266,7 @@ static int parse_relo_and_apply(struct bpf_file *bpf_file, GElf_Shdr *shdr,
insn_idx);
return 1;
}
- else if (sym.st_shndx == bpf_file->dataidx || sym.st_shndx == bpf_file->bssidx) {
+ if (sym.st_shndx == bpf_file->dataidx || sym.st_shndx == bpf_file->bssidx) {
const char *raw = NULL;
int value = 0;
@@ -310,10 +310,10 @@ static int cmp_symbols(const void *l, const void *r)
if (lsym->st_value < rsym->st_value)
return -1;
- else if (lsym->st_value > rsym->st_value)
+ if (lsym->st_value > rsym->st_value)
return 1;
- else
- return 0;
+
+ return 0;
}
static int load_elf_maps_section(struct bpf_file *bpf_file)
@@ -240,7 +240,7 @@ static int add_snd_class(struct media_device_entry *md)
if (strstr(md->node, "timer")) {
md->type = MEDIA_SND_TIMER;
return 0;
- } else if (strstr(md->node, "seq")) {
+ } if (strstr(md->node, "seq")) {
md->type = MEDIA_SND_SEQ;
return 0;
} if (strstr(md->node, "card")) {
@@ -436,7 +436,7 @@ int v4l2_gettryset_fmt_cap (struct v4l2_driver *drv, enum v4l2_direction dir,
perror("VIDIOC_G_FMT failed\n");
}
return ret;
- } else if (dir & (~(V4L2_TRY|V4L2_SET)) ) {
+ } if (dir & (~(V4L2_TRY|V4L2_SET)) ) {
perror ("Invalid direction\n");
return EINVAL;
}
@@ -691,7 +691,7 @@ static void read_rds(struct v4l2_rds *handle, const int fd, const int wait_limit
if (byte_cnt == 0) {
printf("\nEnd of input file reached \n");
break;
- } else if(++error_cnt > 2) {
+ } if(++error_cnt > 2) {
fprintf(stderr, "\nError reading from "
"device (no RDS data available)\n");
break;
@@ -2490,7 +2490,7 @@ static void stateless_m2m(cv4l_fd &fd, cv4l_queue &in, cv4l_queue &out,
if (rc == 0) {
fprintf(stderr, "Timeout when waiting for media request\n");
return;
- } else if (rc < 0) {
+ } if (rc < 0) {
fprintf(stderr, "Unable to select media request: %s\n",
strerror(errno));
return;
@@ -2654,7 +2654,7 @@ static void streaming_set_cap2out(cv4l_fd &fd, cv4l_fd &out_fd)
V4L2_CAP_VIDEO_M2M_MPLANE))) {
fprintf(stderr, "unsupported capture stream type\n");
return;
- } else if (!(out_capabilities & (V4L2_CAP_VIDEO_OUTPUT |
+ } if (!(out_capabilities & (V4L2_CAP_VIDEO_OUTPUT |
V4L2_CAP_VIDEO_OUTPUT_MPLANE |
V4L2_CAP_VIDEO_M2M |
V4L2_CAP_VIDEO_M2M_MPLANE))) {
@@ -287,9 +287,8 @@ static void print_regs(int fd, struct v4l2_dbg_register *reg, unsigned long min,
if (ioctl(fd, VIDIOC_DBG_G_REGISTER, reg) < 0) {
perror("ioctl: VIDIOC_DBG_G_REGISTER failed\n");
break;
- } else {
- printf("%0*llx ", 2 * stride, reg->val);
}
+ printf("%0*llx ", 2 * stride, reg->val);
usleep(1);
}
printf("\n");
Found with clang-tidy's readability-else-after-return Signed-off-by: Rosen Penev <rosenp@gmail.com> --- lib/libdvbv5/dvb-fe.c | 31 +++++++++++++------------ lib/libv4l2rds/libv4l2rds.c | 2 +- lib/libv4lconvert/ov518-decomp.c | 8 +++---- lib/libv4lconvert/spca561-decompress.c | 4 ++-- lib/libv4lconvert/tinyjpeg.c | 2 +- utils/cec-compliance/cec-test-audio.cpp | 8 +++---- utils/cec-compliance/cec-test-power.cpp | 8 +++---- utils/cec-compliance/cec-test.cpp | 31 ++++++++++++------------- utils/cec-follower/cec-follower.cpp | 2 +- utils/cec-follower/cec-processing.cpp | 4 ++-- utils/common/keymap.c | 4 ++-- utils/common/toml.c | 4 ++-- utils/common/v4l-stream.c | 2 +- utils/ir-ctl/ir-ctl.c | 3 +-- utils/keytable/bpf_load.c | 8 +++---- utils/libmedia_dev/get_media_devices.c | 2 +- utils/libv4l2util/v4l2_driver.c | 2 +- utils/rds-ctl/rds-ctl.cpp | 2 +- utils/v4l2-ctl/v4l2-ctl-streaming.cpp | 4 ++-- utils/v4l2-dbg/v4l2-dbg.cpp | 3 +-- 20 files changed, 66 insertions(+), 68 deletions(-)