Skip to content

Commit 1f038b3

Browse files
Merge pull request #614 from hartkopp/master
canxl extension: use plain union instead of typedef
2 parents 7939678 + 392ccc9 commit 1f038b3

File tree

10 files changed

+24
-24
lines changed

10 files changed

+24
-24
lines changed

asc2log.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ static void print_usage(char *prg)
8484
}
8585

8686
static void prframe(FILE *file, struct timeval *tv, int dev,
87-
cu_t *cf, char dir)
87+
union cfu *cf, char dir)
8888
{
8989
static char abuf[BUFLEN];
9090

@@ -177,7 +177,7 @@ static void eval_can(char* buf, struct timeval *date_tvp, char timestamps,
177177
cf.len = CAN_ERR_DLC;
178178

179179
calc_tv(&tv, &read_tv, date_tvp, timestamps, dplace);
180-
prframe(outfile, &tv, interface, (cu_t *)&cf, NO_DIR);
180+
prframe(outfile, &tv, interface, (union cfu *)&cf, NO_DIR);
181181
fflush(outfile);
182182
return;
183183
}
@@ -249,7 +249,7 @@ static void eval_can(char* buf, struct timeval *date_tvp, char timestamps,
249249
cf.data[i] = data[i] & 0xFFU;
250250

251251
calc_tv(&tv, &read_tv, date_tvp, timestamps, dplace);
252-
prframe(outfile, &tv, interface, (cu_t *)&cf, dir[0]);
252+
prframe(outfile, &tv, interface, (union cfu *)&cf, dir[0]);
253253
fflush(outfile);
254254
}
255255
}
@@ -374,7 +374,7 @@ static void eval_canfd(char* buf, struct timeval *date_tvp, char timestamps,
374374
}
375375

376376
calc_tv(&tv, &read_tv, date_tvp, timestamps, dplace);
377-
prframe(outfile, &tv, interface, (cu_t *)&cf, dir[0]);
377+
prframe(outfile, &tv, interface, (union cfu *)&cf, dir[0]);
378378
fflush(outfile);
379379

380380
/* No support for really strange CANFD ErrorFrames format m( */
@@ -487,7 +487,7 @@ static void eval_canxl_cc(char* buf, struct timeval *date_tvp, char timestamps,
487487
cf.len8_dlc = dlc;
488488

489489
calc_tv(&tv, &read_tv, date_tvp, timestamps, dplace);
490-
prframe(outfile, &tv, interface, (cu_t *)&cf, dir[0]);
490+
prframe(outfile, &tv, interface, (union cfu *)&cf, dir[0]);
491491
fflush(outfile);
492492
}
493493

@@ -594,7 +594,7 @@ static void eval_canxl_fd(char* buf, struct timeval *date_tvp, char timestamps,
594594
cf.flags |= CANFD_ESI;
595595

596596
calc_tv(&tv, &read_tv, date_tvp, timestamps, dplace);
597-
prframe(outfile, &tv, interface, (cu_t *)&cf, dir[0]);
597+
prframe(outfile, &tv, interface, (union cfu *)&cf, dir[0]);
598598
fflush(outfile);
599599
}
600600

@@ -723,7 +723,7 @@ static void eval_canxl_xl(char* buf, struct timeval *date_tvp, char timestamps,
723723
cf.flags |= CANXL_RRS;
724724

725725
calc_tv(&tv, &read_tv, date_tvp, timestamps, dplace);
726-
prframe(outfile, &tv, interface, (cu_t *)&cf, dir[0]);
726+
prframe(outfile, &tv, interface, (union cfu *)&cf, dir[0]);
727727
fflush(outfile);
728728

729729
/* No support for CAN XL ErrorFrames */

candump.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ int main(int argc, char **argv)
342342
struct cmsghdr *cmsg;
343343
struct can_filter *rfilter;
344344
can_err_mask_t err_mask;
345-
static cu_t cu; /* union for CAN CC/FD/XL frames */
345+
static union cfu cu; /* union for CAN CC/FD/XL frames */
346346
int nbytes, i;
347347
struct ifreq ifr;
348348
struct timespec ts, last_ts;

cangen.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ static int setsockopt_txtime(int fd)
299299
return 0;
300300
}
301301

302-
static int do_send_one(int fd, cu_t *cu, size_t len, int timeout)
302+
static int do_send_one(int fd, union cfu *cu, size_t len, int timeout)
303303
{
304304
uint8_t control[CMSG_SPACE(sizeof(uint64_t))] = { 0 };
305305
struct iovec iov = {
@@ -494,7 +494,7 @@ int main(int argc, char **argv)
494494
struct can_raw_vcid_options vcid_opts = {
495495
.flags = CAN_RAW_XL_VCID_TX_PASS,
496496
};
497-
static cu_t cu;
497+
static union cfu cu;
498498
int i;
499499
struct ifreq ifr = { 0 };
500500
const int enable_canfx = 1;

canlogserver.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ int main(int argc, char **argv)
191191
.rx_vcid_mask = 0,
192192
};
193193
struct can_filter rfilter;
194-
static cu_t cu; /* union for CAN CC/FD/XL frames */
194+
static union cfu cu; /* union for CAN CC/FD/XL frames */
195195
const int canfx_on = 1;
196196
int nbytes, i, j;
197197
struct ifreq ifr;

canplayer.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ int main(int argc, char **argv)
261261
struct can_raw_vcid_options vcid_opts = {
262262
.flags = CAN_RAW_XL_VCID_TX_PASS,
263263
};
264-
static cu_t cu;
264+
static union cfu cu;
265265
static struct timeval today_tv, log_tv, last_log_tv, diff_tv;
266266
struct timespec sleep_ts;
267267
int s; /* CAN_RAW socket */

cansend.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ int main(int argc, char **argv)
117117
struct can_raw_vcid_options vcid_opts = {
118118
.flags = CAN_RAW_XL_VCID_TX_PASS,
119119
};
120-
static cu_t cu;
120+
static union cfu cu;
121121
struct ifreq ifr;
122122

123123
/* check command line options */

lib.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ int hexstring2data(char *arg, unsigned char *data, int maxdlen)
155155
return 0;
156156
}
157157

158-
int parse_canframe(char *cs, cu_t *cu)
158+
int parse_canframe(char *cs, union cfu *cu)
159159
{
160160
/* documentation see lib.h */
161161

@@ -309,7 +309,7 @@ int parse_canframe(char *cs, cu_t *cu)
309309
return mtu;
310310
}
311311

312-
int snprintf_canframe(char *buf, size_t size, cu_t *cu, int sep)
312+
int snprintf_canframe(char *buf, size_t size, union cfu *cu, int sep)
313313
{
314314
/* documentation see lib.h */
315315

@@ -433,7 +433,7 @@ int snprintf_canframe(char *buf, size_t size, cu_t *cu, int sep)
433433
return offset;
434434
}
435435

436-
int snprintf_long_canframe(char *buf, size_t size, cu_t *cu, int view)
436+
int snprintf_long_canframe(char *buf, size_t size, union cfu *cu, int view)
437437
{
438438
/* documentation see lib.h */
439439

lib.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,11 @@ static inline int pr_debug(const char* fmt, ...) {return 0;}
5959
#endif
6060

6161
/* CAN CC/FD/XL frame union */
62-
typedef union {
62+
union cfu {
6363
struct can_frame cc;
6464
struct canfd_frame fd;
6565
struct canxl_frame xl;
66-
} cu_t;
66+
};
6767

6868
/*
6969
* The buffer size for ASCII CAN frame string representations
@@ -110,7 +110,7 @@ int hexstring2data(char *arg, unsigned char *data, int maxdlen);
110110
*
111111
*/
112112

113-
int parse_canframe(char *cs, cu_t *cu);
113+
int parse_canframe(char *cs, union cfu *cu);
114114
/*
115115
* Transfers a valid ASCII string describing a CAN frame into the CAN union
116116
* containing CAN CC/FD/XL structs.
@@ -180,7 +180,7 @@ int parse_canframe(char *cs, cu_t *cu);
180180
* - CAN FD frames do not have a RTR bit
181181
*/
182182

183-
int snprintf_canframe(char *buf, size_t size, cu_t *cu, int sep);
183+
int snprintf_canframe(char *buf, size_t size, union cfu *cu, int sep);
184184
/*
185185
* Creates a CAN frame hexadecimal output in compact format.
186186
* The CAN data[] is separated by '.' when sep != 0.
@@ -213,7 +213,7 @@ int snprintf_canframe(char *buf, size_t size, cu_t *cu, int sep);
213213

214214
#define SWAP_DELIMITER '`'
215215

216-
int snprintf_long_canframe(char *buf, size_t size, cu_t *cu, int view);
216+
int snprintf_long_canframe(char *buf, size_t size, union cfu *cu, int view);
217217
/*
218218
* Creates a CAN frame hexadecimal output in user readable format.
219219
*

log2asc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ static void canfd_asc(struct canfd_frame *cf, int devno, int mtu,
183183
fprintf(outfile, " %8d %4d %8X 0 0 0 0 0", 130000, 130, flags);
184184
}
185185

186-
static void canxl_asc(cu_t *cu, int devno, int mtu,
186+
static void canxl_asc(union cfu *cu, int devno, int mtu,
187187
char *extra_info, FILE *outfile)
188188
{
189189
char id[10];
@@ -314,7 +314,7 @@ int main(int argc, char **argv)
314314
{
315315
static char buf[BUFSZ], device[DEVSZ], afrbuf[AFRSZ], extra_info[EXTRASZ];
316316

317-
static cu_t cu;
317+
static union cfu cu;
318318
static struct timeval tv, start_tv;
319319
FILE *infile = stdin;
320320
FILE *outfile = stdout;

log2long.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
int main(void)
6969
{
7070
static char buf[BUFSZ], timestamp[TIMESZ], device[DEVSZ], afrbuf[AFRSZ];
71-
static cu_t cu;
71+
static union cfu cu;
7272
int mtu;
7373

7474
while (fgets(buf, BUFSZ-1, stdin)) {

0 commit comments

Comments
 (0)