From 65e715d56d08a76c22f5ae2665ca0696e2834c89 Mon Sep 17 00:00:00 2001 From: Darcy Phipps Date: Fri, 5 Dec 2025 08:57:59 -0500 Subject: [PATCH] candump: Use SCM_* consts instead of SO_* for cmsg_type There are explicit #defines for SCM_TIMESTAMP and SCM_TIMESTAMPING. They currently happen to have the same value as SO_TIMESTAMP and SO_TIMESTAMPING but the former should be used when checking cmsg_type in case one day they do not. --- candump.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/candump.c b/candump.c index 1862d0a..8b9bf59 100644 --- a/candump.c +++ b/candump.c @@ -72,6 +72,9 @@ #ifndef SO_TIMESTAMPING #define SO_TIMESTAMPING 37 #endif +#ifndef SCM_TIMESTAMPING +#define SCM_TIMESTAMPING SO_TIMESTAMPING +#endif #define TIMESTAMPSZ 50 /* string 'absolute with date' requires max 49 bytes */ @@ -807,13 +810,13 @@ int main(int argc, char **argv) for (cmsg = CMSG_FIRSTHDR(&msg); cmsg && (cmsg->cmsg_level == SOL_SOCKET); cmsg = CMSG_NXTHDR(&msg,cmsg)) { - if (cmsg->cmsg_type == SO_TIMESTAMP) { + if (cmsg->cmsg_type == SCM_TIMESTAMP) { struct timeval tv; memcpy(&tv, CMSG_DATA(cmsg), sizeof(tv)); ts.tv_sec = tv.tv_sec; ts.tv_nsec = tv.tv_usec; ts.tv_nsec *= 1000; - } else if (cmsg->cmsg_type == SO_TIMESTAMPING) { + } else if (cmsg->cmsg_type == SCM_TIMESTAMPING) { struct timespec *stamp = (struct timespec *)CMSG_DATA(cmsg); /*