Merge pull request #394 from marckleinebudde/candump-cleanups

candump cleanups
pull/396/head
Marc Kleine-Budde 2023-01-03 10:49:40 +01:00 committed by GitHub
commit aadf98b49b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 10 deletions

View File

@ -223,7 +223,6 @@ static inline void sprint_timestamp(const char timestamp, const struct timeval *
struct timeval *const last_tv, char *ts_buffer) struct timeval *const last_tv, char *ts_buffer)
{ {
switch (timestamp) { switch (timestamp) {
case 'a': /* absolute with timestamp */ case 'a': /* absolute with timestamp */
sprintf(ts_buffer, "(%010lu.%06lu) ", tv->tv_sec, tv->tv_usec); sprintf(ts_buffer, "(%010lu.%06lu) ", tv->tv_sec, tv->tv_usec);
break; break;
@ -325,7 +324,7 @@ int main(int argc, char **argv)
progname = basename(argv[0]); progname = basename(argv[0]);
while ((opt = getopt(argc, argv, "t:HciaSs:lDdxLf:n:r:he8T:?")) != -1) { while ((opt = getopt(argc, argv, "t:HciaSs:lf:Ln:r:Dde8xT:h?")) != -1) {
switch (opt) { switch (opt) {
case 't': case 't':
timestamp = optarg[0]; timestamp = optarg[0];
@ -521,7 +520,6 @@ int main(int argc, char **argv)
addr.can_ifindex = 0; /* any can interface */ addr.can_ifindex = 0; /* any can interface */
if (nptr) { if (nptr) {
/* found a ',' after the interface name => check for filters */ /* found a ',' after the interface name => check for filters */
/* determine number of filters to alloc the filter space */ /* determine number of filters to alloc the filter space */
@ -755,7 +753,6 @@ int main(int argc, char **argv)
if (cmsg->cmsg_type == SO_TIMESTAMP) { if (cmsg->cmsg_type == SO_TIMESTAMP) {
memcpy(&tv, CMSG_DATA(cmsg), sizeof(tv)); memcpy(&tv, CMSG_DATA(cmsg), sizeof(tv));
} else if (cmsg->cmsg_type == SO_TIMESTAMPING) { } else if (cmsg->cmsg_type == SO_TIMESTAMPING) {
struct timespec *stamp = (struct timespec *)CMSG_DATA(cmsg); struct timespec *stamp = (struct timespec *)CMSG_DATA(cmsg);
/* /*
@ -766,14 +763,14 @@ int main(int argc, char **argv)
* linux/Documentation/networking/timestamping.txt * linux/Documentation/networking/timestamping.txt
*/ */
tv.tv_sec = stamp[2].tv_sec; tv.tv_sec = stamp[2].tv_sec;
tv.tv_usec = stamp[2].tv_nsec/1000; tv.tv_usec = stamp[2].tv_nsec / 1000;
} else if (cmsg->cmsg_type == SO_RXQ_OVFL) } else if (cmsg->cmsg_type == SO_RXQ_OVFL) {
memcpy(&obj->dropcnt, CMSG_DATA(cmsg), sizeof(__u32)); memcpy(&obj->dropcnt, CMSG_DATA(cmsg), sizeof(__u32));
}
} }
/* check for (unlikely) dropped frames on this specific socket */ /* check for (unlikely) dropped frames on this specific socket */
if (obj->dropcnt != obj->last_dropcnt) { if (obj->dropcnt != obj->last_dropcnt) {
__u32 frames = obj->dropcnt - obj->last_dropcnt; __u32 frames = obj->dropcnt - obj->last_dropcnt;
if (silent != SILENT_ON) if (silent != SILENT_ON)
@ -811,7 +808,7 @@ int main(int argc, char **argv)
extra_info); extra_info);
} }
if ((logfrmt) && (silent == SILENT_OFF)){ if ((logfrmt) && (silent == SILENT_OFF)) {
char buf[CL_CFSZ]; /* max length */ char buf[CL_CFSZ]; /* max length */
/* print CAN frame in log file style to stdout */ /* print CAN frame in log file style to stdout */
@ -824,7 +821,7 @@ int main(int argc, char **argv)
goto out_fflush; /* no other output to stdout */ goto out_fflush; /* no other output to stdout */
} }
if (silent != SILENT_OFF){ if (silent != SILENT_OFF) {
if (silent == SILENT_ANI) { if (silent == SILENT_ANI) {
printf("%c\b", anichar[silentani %= MAXANI]); printf("%c\b", anichar[silentani %= MAXANI]);
silentani++; silentani++;
@ -838,7 +835,6 @@ int main(int argc, char **argv)
printf("%*s", max_devname_len, devname[idx]); printf("%*s", max_devname_len, devname[idx]);
if (extra_msg_info) { if (extra_msg_info) {
if (msg.msg_flags & MSG_DONTROUTE) if (msg.msg_flags & MSG_DONTROUTE)
printf (" TX %s", extra_m_info[frame.flags & 3]); printf (" TX %s", extra_m_info[frame.flags & 3]);
else else