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
parent
5a93509655
commit
17a5fe6022
|
|
@ -359,8 +359,7 @@ int get_date(struct timeval *tv, char *date) {
|
|||
before parsing the real year value (hack) */
|
||||
if (!strptime(date, "%B %d %I:%M:%S.%Y %p %Y", &tms))
|
||||
return 1;
|
||||
else
|
||||
sscanf(date, "%*s %*d %*d:%*d:%*d.%3u ", &msecs);
|
||||
sscanf(date, "%*s %*d %*d:%*d:%*d.%3u ", &msecs);
|
||||
}
|
||||
|
||||
} else {
|
||||
|
|
@ -377,8 +376,7 @@ int get_date(struct timeval *tv, char *date) {
|
|||
before parsing the real year value (hack) */
|
||||
if (!strptime(date, "%B %d %H:%M:%S.%Y %Y", &tms))
|
||||
return 1;
|
||||
else
|
||||
sscanf(date, "%*s %*d %*d:%*d:%*d.%3u ", &msecs);
|
||||
sscanf(date, "%*s %*d %*d:%*d:%*d.%3u ", &msecs);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
42
canfdtest.c
42
canfdtest.c
|
|
@ -181,20 +181,18 @@ static int send_frame(struct can_frame *frame)
|
|||
|
||||
while ((ret = send(sockfd, frame, sizeof(*frame), 0))
|
||||
!= sizeof(*frame)) {
|
||||
if (ret < 0) {
|
||||
if (errno != ENOBUFS) {
|
||||
perror("send failed");
|
||||
return -1;
|
||||
} else {
|
||||
if (verbose) {
|
||||
printf("N");
|
||||
fflush(stdout);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (ret >= 0) {
|
||||
fprintf(stderr, "send returned %d", ret);
|
||||
return -1;
|
||||
}
|
||||
if (errno != ENOBUFS) {
|
||||
perror("send failed");
|
||||
return -1;
|
||||
}
|
||||
if (verbose) {
|
||||
printf("N");
|
||||
fflush(stdout);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -332,19 +330,19 @@ static int can_echo_gen(void)
|
|||
if (recv_tx_pos == inflight_count)
|
||||
recv_tx_pos = 0;
|
||||
continue;
|
||||
} else {
|
||||
if (!recv_tx[recv_rx_pos]) {
|
||||
printf("RX before TX!\n");
|
||||
print_frame(&rx_frame, 0);
|
||||
running = 0;
|
||||
}
|
||||
/* compare with expected */
|
||||
compare_frame(&tx_frames[recv_rx_pos], &rx_frame, 1);
|
||||
recv_rx_pos++;
|
||||
if (recv_rx_pos == inflight_count)
|
||||
recv_rx_pos = 0;
|
||||
}
|
||||
|
||||
if (!recv_tx[recv_rx_pos]) {
|
||||
printf("RX before TX!\n");
|
||||
print_frame(&rx_frame, 0);
|
||||
running = 0;
|
||||
}
|
||||
/* compare with expected */
|
||||
compare_frame(&tx_frames[recv_rx_pos], &rx_frame, 1);
|
||||
recv_rx_pos++;
|
||||
if (recv_rx_pos == inflight_count)
|
||||
recv_rx_pos = 0;
|
||||
|
||||
loops++;
|
||||
if (test_loops && loops >= test_loops)
|
||||
break;
|
||||
|
|
|
|||
4
cangen.c
4
cangen.c
|
|
@ -468,8 +468,8 @@ resend:
|
|||
if (poll(&fds, 1, polltimeout) < 0) {
|
||||
perror("poll");
|
||||
return 1;
|
||||
} else
|
||||
goto resend;
|
||||
}
|
||||
goto resend;
|
||||
} else
|
||||
enobufs_count++;
|
||||
|
||||
|
|
|
|||
|
|
@ -300,8 +300,7 @@ int main(int argc, char **argv)
|
|||
//printf("accepted\n");
|
||||
if (!fork())
|
||||
break;
|
||||
else
|
||||
close(accsocket);
|
||||
close(accsocket);
|
||||
}
|
||||
else if (errno != EINTR) {
|
||||
perror("accept");
|
||||
|
|
|
|||
96
isotpdump.c
96
isotpdump.c
|
|
@ -335,65 +335,66 @@ int main(int argc, char **argv)
|
|||
if (nbytes < 0) {
|
||||
perror("read");
|
||||
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);
|
||||
return 1;
|
||||
} else {
|
||||
}
|
||||
if (frame.can_id == src && ext && !extany &&
|
||||
extaddr != frame.data[0])
|
||||
continue;
|
||||
|
||||
if (frame.can_id == src && ext && !extany && extaddr != frame.data[0])
|
||||
continue;
|
||||
if (frame.can_id == dst && rx_ext && !rx_extany &&
|
||||
rx_extaddr != frame.data[0])
|
||||
continue;
|
||||
|
||||
if (frame.can_id == dst && rx_ext && !rx_extany && rx_extaddr != frame.data[0])
|
||||
continue;
|
||||
if (color)
|
||||
printf("%s", (frame.can_id == src) ? FGRED : FGBLUE);
|
||||
|
||||
if (color)
|
||||
printf("%s", (frame.can_id == src)? FGRED:FGBLUE);
|
||||
if (timestamp) {
|
||||
ioctl(s, SIOCGSTAMP, &tv);
|
||||
|
||||
if (timestamp) {
|
||||
ioctl(s, SIOCGSTAMP, &tv);
|
||||
|
||||
|
||||
switch (timestamp) {
|
||||
|
||||
case 'a': /* absolute with timestamp */
|
||||
printf("(%lu.%06lu) ", tv.tv_sec, tv.tv_usec);
|
||||
break;
|
||||
|
||||
case 'A': /* absolute with date */
|
||||
{
|
||||
struct tm tm;
|
||||
char timestring[25];
|
||||
|
||||
tm = *localtime(&tv.tv_sec);
|
||||
strftime(timestring, 24, "%Y-%m-%d %H:%M:%S", &tm);
|
||||
printf("(%s.%06lu) ", timestring, tv.tv_usec);
|
||||
}
|
||||
switch (timestamp) {
|
||||
case 'a': /* absolute with timestamp */
|
||||
printf("(%lu.%06lu) ", tv.tv_sec, tv.tv_usec);
|
||||
break;
|
||||
|
||||
case 'd': /* delta */
|
||||
case 'z': /* starting with zero */
|
||||
{
|
||||
struct timeval diff;
|
||||
case 'A': /* absolute with date */
|
||||
{
|
||||
struct tm tm;
|
||||
char timestring[25];
|
||||
|
||||
if (last_tv.tv_sec == 0) /* first init */
|
||||
last_tv = tv;
|
||||
diff.tv_sec = tv.tv_sec - last_tv.tv_sec;
|
||||
diff.tv_usec = tv.tv_usec - last_tv.tv_usec;
|
||||
if (diff.tv_usec < 0)
|
||||
diff.tv_sec--, diff.tv_usec += 1000000;
|
||||
if (diff.tv_sec < 0)
|
||||
diff.tv_sec = diff.tv_usec = 0;
|
||||
printf("(%lu.%06lu) ", diff.tv_sec, diff.tv_usec);
|
||||
tm = *localtime(&tv.tv_sec);
|
||||
strftime(timestring, 24, "%Y-%m-%d %H:%M:%S",
|
||||
&tm);
|
||||
printf("(%s.%06lu) ", timestring, tv.tv_usec);
|
||||
} break;
|
||||
|
||||
if (timestamp == 'd')
|
||||
last_tv = tv; /* update for delta calculation */
|
||||
}
|
||||
case 'd': /* delta */
|
||||
case 'z': /* starting with zero */
|
||||
{
|
||||
struct timeval diff;
|
||||
|
||||
if (last_tv.tv_sec == 0) /* first init */
|
||||
last_tv = tv;
|
||||
diff.tv_sec = tv.tv_sec - last_tv.tv_sec;
|
||||
diff.tv_usec = tv.tv_usec - last_tv.tv_usec;
|
||||
if (diff.tv_usec < 0)
|
||||
diff.tv_sec--, diff.tv_usec += 1000000;
|
||||
if (diff.tv_sec < 0)
|
||||
diff.tv_sec = diff.tv_usec = 0;
|
||||
printf("(%lu.%06lu) ", diff.tv_sec,
|
||||
diff.tv_usec);
|
||||
|
||||
if (timestamp == 'd')
|
||||
last_tv =
|
||||
tv; /* update for delta calculation */
|
||||
} break;
|
||||
|
||||
default: /* no timestamp output */
|
||||
break;
|
||||
|
||||
default: /* no timestamp output */
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (frame.can_id & CAN_EFF_FLAG)
|
||||
printf(" %s %8X", argv[optind], frame.can_id & CAN_EFF_MASK);
|
||||
|
|
@ -501,7 +502,6 @@ int main(int argc, char **argv)
|
|||
printf("%s", ATTRESET);
|
||||
printf("\n");
|
||||
fflush(stdout);
|
||||
}
|
||||
}
|
||||
|
||||
close(s);
|
||||
|
|
|
|||
21
isotpperf.c
21
isotpperf.c
|
|
@ -223,19 +223,21 @@ int main(int argc, char **argv)
|
|||
ret = nbytes;
|
||||
running = 0;
|
||||
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);
|
||||
ret = nbytes;
|
||||
running = 0;
|
||||
continue;
|
||||
} else {
|
||||
if (rcvlen) {
|
||||
/* make sure to process only the detected PDU CAN frame type */
|
||||
if (canfd_on && (nbytes != CANFD_MTU))
|
||||
continue;
|
||||
if (!canfd_on && (nbytes != CAN_MTU))
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (rcvlen) {
|
||||
/* make sure to process only the detected PDU CAN frame type */
|
||||
if (canfd_on && (nbytes != CANFD_MTU))
|
||||
continue;
|
||||
if (!canfd_on && (nbytes != CAN_MTU))
|
||||
continue;
|
||||
}
|
||||
|
||||
/* check extended address if provided */
|
||||
if (ext && extaddr != frame.data[0])
|
||||
|
|
@ -408,7 +410,6 @@ int main(int argc, char **argv)
|
|||
fflen = rcvlen = 0;
|
||||
}
|
||||
fflush(stdout);
|
||||
}
|
||||
}
|
||||
|
||||
close(s);
|
||||
|
|
|
|||
|
|
@ -383,10 +383,9 @@ static inline int addr_status_mine(int sa)
|
|||
{
|
||||
if (sa == s.current_sa)
|
||||
return '*';
|
||||
else if (addr[sa].flags & F_USE)
|
||||
if (addr[sa].flags & F_USE)
|
||||
return '+';
|
||||
else
|
||||
return '-';
|
||||
return '-';
|
||||
}
|
||||
|
||||
static void dump_status(void)
|
||||
|
|
|
|||
13
j1939cat.c
13
j1939cat.c
|
|
@ -212,8 +212,7 @@ static int j1939cat_extract_serr(struct j1939cat_priv *priv)
|
|||
|
||||
if (serr->ee_info == SCM_TSTAMP_SCHED)
|
||||
return -EINTR;
|
||||
else
|
||||
return 0;
|
||||
return 0;
|
||||
case SO_EE_ORIGIN_LOCAL:
|
||||
/*
|
||||
* The serr->ee_origin == SO_EE_ORIGIN_LOCAL is
|
||||
|
|
@ -319,11 +318,10 @@ static int j1939cat_send_loop(struct j1939cat_priv *priv, int out_fd, char *buf,
|
|||
ret = poll(&fds, 1, priv->polltimeout);
|
||||
if (ret == -EINTR)
|
||||
continue;
|
||||
else if (ret < 0)
|
||||
if (ret < 0)
|
||||
return -errno;
|
||||
else if (!ret)
|
||||
if (!ret)
|
||||
return -ETIME;
|
||||
|
||||
if (!(fds.revents & events)) {
|
||||
warn("%s: something else is wrong", __func__);
|
||||
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);
|
||||
if (ret == -EINTR)
|
||||
continue;
|
||||
else if (ret)
|
||||
if (ret)
|
||||
return ret;
|
||||
else if ((priv->repeat - 1) == stats->tskey)
|
||||
if ((priv->repeat - 1) == stats->tskey)
|
||||
tx_done = true;
|
||||
|
||||
}
|
||||
|
||||
if (fds.revents & POLLOUT) {
|
||||
|
|
|
|||
2
lib.c
2
lib.c
|
|
@ -588,7 +588,7 @@ void snprintf_can_error_frame(char *buf, size_t len, const struct canfd_frame *c
|
|||
if (class & mask) {
|
||||
if (classes)
|
||||
n += snprintf(buf + n, len - n, "%s", sep);
|
||||
n += snprintf(buf + n, len - n, "%s", error_classes[i]);
|
||||
n += snprintf(buf + n, len - n, "%s", error_classes[i]);
|
||||
if (mask == CAN_ERR_LOSTARB)
|
||||
n += snprintf_error_lostarb(buf + n, len - n,
|
||||
cf);
|
||||
|
|
|
|||
|
|
@ -64,8 +64,8 @@ static const char *libj1939_ifnam(int ifindex)
|
|||
*/
|
||||
libj1939_cleanup();
|
||||
return libj1939_ifnam(ifindex);
|
||||
} else
|
||||
return NULL;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* retrieve index */
|
||||
|
|
@ -88,8 +88,8 @@ static int libj1939_ifindex(const char *str)
|
|||
if (cached) {
|
||||
libj1939_cleanup();
|
||||
return libj1939_ifindex(str);
|
||||
} else
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void libj1939_parse_canaddr(char *spec, struct sockaddr_can *paddr)
|
||||
|
|
|
|||
Loading…
Reference in New Issue