clang-tidy: do not use else after return

Found with readability-else-after-return

Signed-off-by: Rosen Penev <rosenp@gmail.com>
pull/250/head
Rosen Penev 2020-10-12 00:08:10 -07:00
parent 5a93509655
commit 17a5fe6022
No known key found for this signature in database
GPG Key ID: 36D31CFA845F0E3B
10 changed files with 101 additions and 109 deletions

View File

@ -359,7 +359,6 @@ int get_date(struct timeval *tv, char *date) {
before parsing the real year value (hack) */ before parsing the real year value (hack) */
if (!strptime(date, "%B %d %I:%M:%S.%Y %p %Y", &tms)) if (!strptime(date, "%B %d %I:%M:%S.%Y %p %Y", &tms))
return 1; return 1;
else
sscanf(date, "%*s %*d %*d:%*d:%*d.%3u ", &msecs); sscanf(date, "%*s %*d %*d:%*d:%*d.%3u ", &msecs);
} }
@ -377,7 +376,6 @@ int get_date(struct timeval *tv, char *date) {
before parsing the real year value (hack) */ before parsing the real year value (hack) */
if (!strptime(date, "%B %d %H:%M:%S.%Y %Y", &tms)) if (!strptime(date, "%B %d %H:%M:%S.%Y %Y", &tms))
return 1; return 1;
else
sscanf(date, "%*s %*d %*d:%*d:%*d.%3u ", &msecs); sscanf(date, "%*s %*d %*d:%*d:%*d.%3u ", &msecs);
} }
} }

View File

@ -181,21 +181,19 @@ static int send_frame(struct can_frame *frame)
while ((ret = send(sockfd, frame, sizeof(*frame), 0)) while ((ret = send(sockfd, frame, sizeof(*frame), 0))
!= sizeof(*frame)) { != sizeof(*frame)) {
if (ret < 0) { if (ret >= 0) {
fprintf(stderr, "send returned %d", ret);
return -1;
}
if (errno != ENOBUFS) { if (errno != ENOBUFS) {
perror("send failed"); perror("send failed");
return -1; return -1;
} else { }
if (verbose) { if (verbose) {
printf("N"); printf("N");
fflush(stdout); fflush(stdout);
} }
} }
} else {
fprintf(stderr, "send returned %d", ret);
return -1;
}
}
return 0; return 0;
} }
@ -332,7 +330,8 @@ static int can_echo_gen(void)
if (recv_tx_pos == inflight_count) if (recv_tx_pos == inflight_count)
recv_tx_pos = 0; recv_tx_pos = 0;
continue; continue;
} else { }
if (!recv_tx[recv_rx_pos]) { if (!recv_tx[recv_rx_pos]) {
printf("RX before TX!\n"); printf("RX before TX!\n");
print_frame(&rx_frame, 0); print_frame(&rx_frame, 0);
@ -343,7 +342,6 @@ static int can_echo_gen(void)
recv_rx_pos++; recv_rx_pos++;
if (recv_rx_pos == inflight_count) if (recv_rx_pos == inflight_count)
recv_rx_pos = 0; recv_rx_pos = 0;
}
loops++; loops++;
if (test_loops && loops >= test_loops) if (test_loops && loops >= test_loops)

View File

@ -468,7 +468,7 @@ resend:
if (poll(&fds, 1, polltimeout) < 0) { if (poll(&fds, 1, polltimeout) < 0) {
perror("poll"); perror("poll");
return 1; return 1;
} else }
goto resend; goto resend;
} else } else
enobufs_count++; enobufs_count++;

View File

@ -300,7 +300,6 @@ int main(int argc, char **argv)
//printf("accepted\n"); //printf("accepted\n");
if (!fork()) if (!fork())
break; break;
else
close(accsocket); close(accsocket);
} }
else if (errno != EINTR) { else if (errno != EINTR) {

View File

@ -335,15 +335,17 @@ int main(int argc, char **argv)
if (nbytes < 0) { if (nbytes < 0) {
perror("read"); perror("read");
return 1; return 1;
} else if (nbytes != CAN_MTU && nbytes != CANFD_MTU) { }
if (nbytes != CAN_MTU && nbytes != CANFD_MTU) {
fprintf(stderr, "read: incomplete CAN frame %zu %d\n", sizeof(frame), nbytes); fprintf(stderr, "read: incomplete CAN frame %zu %d\n", sizeof(frame), nbytes);
return 1; return 1;
} else { }
if (frame.can_id == src && ext && !extany &&
if (frame.can_id == src && ext && !extany && extaddr != frame.data[0]) extaddr != frame.data[0])
continue; continue;
if (frame.can_id == dst && rx_ext && !rx_extany && rx_extaddr != frame.data[0]) if (frame.can_id == dst && rx_ext && !rx_extany &&
rx_extaddr != frame.data[0])
continue; continue;
if (color) if (color)
@ -352,9 +354,7 @@ int main(int argc, char **argv)
if (timestamp) { if (timestamp) {
ioctl(s, SIOCGSTAMP, &tv); ioctl(s, SIOCGSTAMP, &tv);
switch (timestamp) { switch (timestamp) {
case 'a': /* absolute with timestamp */ case 'a': /* absolute with timestamp */
printf("(%lu.%06lu) ", tv.tv_sec, tv.tv_usec); printf("(%lu.%06lu) ", tv.tv_sec, tv.tv_usec);
break; break;
@ -365,10 +365,10 @@ int main(int argc, char **argv)
char timestring[25]; char timestring[25];
tm = *localtime(&tv.tv_sec); tm = *localtime(&tv.tv_sec);
strftime(timestring, 24, "%Y-%m-%d %H:%M:%S", &tm); strftime(timestring, 24, "%Y-%m-%d %H:%M:%S",
&tm);
printf("(%s.%06lu) ", timestring, tv.tv_usec); printf("(%s.%06lu) ", timestring, tv.tv_usec);
} } break;
break;
case 'd': /* delta */ case 'd': /* delta */
case 'z': /* starting with zero */ case 'z': /* starting with zero */
@ -383,12 +383,13 @@ int main(int argc, char **argv)
diff.tv_sec--, diff.tv_usec += 1000000; diff.tv_sec--, diff.tv_usec += 1000000;
if (diff.tv_sec < 0) if (diff.tv_sec < 0)
diff.tv_sec = diff.tv_usec = 0; diff.tv_sec = diff.tv_usec = 0;
printf("(%lu.%06lu) ", diff.tv_sec, diff.tv_usec); printf("(%lu.%06lu) ", diff.tv_sec,
diff.tv_usec);
if (timestamp == 'd') if (timestamp == 'd')
last_tv = tv; /* update for delta calculation */ last_tv =
} tv; /* update for delta calculation */
break; } break;
default: /* no timestamp output */ default: /* no timestamp output */
break; break;
@ -502,7 +503,6 @@ int main(int argc, char **argv)
printf("\n"); printf("\n");
fflush(stdout); fflush(stdout);
} }
}
close(s); close(s);

View File

@ -223,12 +223,14 @@ int main(int argc, char **argv)
ret = nbytes; ret = nbytes;
running = 0; running = 0;
continue; continue;
} else if (nbytes != CAN_MTU && nbytes != CANFD_MTU) { }
if (nbytes != CAN_MTU && nbytes != CANFD_MTU) {
fprintf(stderr, "read: incomplete CAN frame %zu %d\n", sizeof(frame), nbytes); fprintf(stderr, "read: incomplete CAN frame %zu %d\n", sizeof(frame), nbytes);
ret = nbytes; ret = nbytes;
running = 0; running = 0;
continue; continue;
} else { }
if (rcvlen) { if (rcvlen) {
/* make sure to process only the detected PDU CAN frame type */ /* make sure to process only the detected PDU CAN frame type */
if (canfd_on && (nbytes != CANFD_MTU)) if (canfd_on && (nbytes != CANFD_MTU))
@ -409,7 +411,6 @@ int main(int argc, char **argv)
} }
fflush(stdout); fflush(stdout);
} }
}
close(s); close(s);

View File

@ -383,9 +383,8 @@ static inline int addr_status_mine(int sa)
{ {
if (sa == s.current_sa) if (sa == s.current_sa)
return '*'; return '*';
else if (addr[sa].flags & F_USE) if (addr[sa].flags & F_USE)
return '+'; return '+';
else
return '-'; return '-';
} }

View File

@ -212,7 +212,6 @@ static int j1939cat_extract_serr(struct j1939cat_priv *priv)
if (serr->ee_info == SCM_TSTAMP_SCHED) if (serr->ee_info == SCM_TSTAMP_SCHED)
return -EINTR; return -EINTR;
else
return 0; return 0;
case SO_EE_ORIGIN_LOCAL: case SO_EE_ORIGIN_LOCAL:
/* /*
@ -319,11 +318,10 @@ static int j1939cat_send_loop(struct j1939cat_priv *priv, int out_fd, char *buf,
ret = poll(&fds, 1, priv->polltimeout); ret = poll(&fds, 1, priv->polltimeout);
if (ret == -EINTR) if (ret == -EINTR)
continue; continue;
else if (ret < 0) if (ret < 0)
return -errno; return -errno;
else if (!ret) if (!ret)
return -ETIME; return -ETIME;
if (!(fds.revents & events)) { if (!(fds.revents & events)) {
warn("%s: something else is wrong", __func__); warn("%s: something else is wrong", __func__);
return -EIO; return -EIO;
@ -333,11 +331,10 @@ static int j1939cat_send_loop(struct j1939cat_priv *priv, int out_fd, char *buf,
ret = j1939cat_recv_err(priv); ret = j1939cat_recv_err(priv);
if (ret == -EINTR) if (ret == -EINTR)
continue; continue;
else if (ret) if (ret)
return ret; return ret;
else if ((priv->repeat - 1) == stats->tskey) if ((priv->repeat - 1) == stats->tskey)
tx_done = true; tx_done = true;
} }
if (fds.revents & POLLOUT) { if (fds.revents & POLLOUT) {

View File

@ -64,7 +64,7 @@ static const char *libj1939_ifnam(int ifindex)
*/ */
libj1939_cleanup(); libj1939_cleanup();
return libj1939_ifnam(ifindex); return libj1939_ifnam(ifindex);
} else }
return NULL; return NULL;
} }
@ -88,7 +88,7 @@ static int libj1939_ifindex(const char *str)
if (cached) { if (cached) {
libj1939_cleanup(); libj1939_cleanup();
return libj1939_ifindex(str); return libj1939_ifindex(str);
} else }
return 0; return 0;
} }