#include <linux/can/bcm.h>
#define MAXLEN 100
+#define FORMATSZ 80
#define PORT 28600
void childdied(int i)
sigset_t sigset;
char buf[MAXLEN];
+ char format[FORMATSZ];
char rxmsg[50];
struct {
struct can_frame frame;
} msg;
+ if (snprintf(format, FORMATSZ, "< %%%ds %%c %%lu %%lu %%x %%hhu "
+ "%%hhx %%hhx %%hhx %%hhx %%hhx %%hhx "
+ "%%hhx %%hhx >", IFNAMSIZ-1) >= FORMATSZ-1)
+ exit(1);
+
sigemptyset(&sigset);
signalaction.sa_handler = &childdied;
signalaction.sa_mask = sigset;
memset(&msg, 0, sizeof(msg));
msg.msg_head.nframes = 1;
- items = sscanf(buf, "< %6s %c %lu %lu %x %hhu "
- "%hhx %hhx %hhx %hhx %hhx %hhx "
- "%hhx %hhx >",
+ items = sscanf(buf, format,
ifr.ifr_name,
&cmd,
&msg.msg_head.ival2.tv_sec,