cansequence: convert towards kernel coding style

pull/476/head
Marc Kleine-Budde 2023-11-29 17:22:20 +01:00
parent 85da9de8d8
commit 5c433340c3
1 changed files with 24 additions and 23 deletions

View File

@ -47,12 +47,15 @@ static struct can_frame frame = {
.can_dlc = 1, .can_dlc = 1,
}; };
static struct can_filter filter[] = { static struct can_filter filter[] = {
{ .can_id = CAN_ID_DEFAULT, }, {
.can_id = CAN_ID_DEFAULT,
},
}; };
static void print_usage(char *prg) static void print_usage(char *prg)
{ {
fprintf(stderr, "Usage: %s [<can-interface>] [Options]\n" fprintf(stderr,
"Usage: %s [<can-interface>] [Options]\n"
"\n" "\n"
"cansequence sends CAN messages with a rising sequence number as payload.\n" "cansequence sends CAN messages with a rising sequence number as payload.\n"
"When the -r option is given, cansequence expects to receive these messages\n" "When the -r option is given, cansequence expects to receive these messages\n"
@ -77,7 +80,6 @@ static void sig_handler(int signo)
signal_num = signo; signal_num = signo;
} }
static void do_receive() static void do_receive()
{ {
uint8_t ctrlmsg[CMSG_SPACE(sizeof(struct timeval)) + CMSG_SPACE(sizeof(__u32))]; uint8_t ctrlmsg[CMSG_SPACE(sizeof(struct timeval)) + CMSG_SPACE(sizeof(__u32))];
@ -188,7 +190,6 @@ static void do_receive()
sequence++; sequence++;
if (verbose && !(sequence & sequence_mask)) if (verbose && !(sequence & sequence_mask))
printf("sequence wrap around (%d)\n", sequence_wrap++); printf("sequence wrap around (%d)\n", sequence_wrap++);
} }
} }
@ -203,7 +204,7 @@ static void do_send()
if (verbose > 1) if (verbose > 1)
printf("sending frame. sequence number: %d\n", sequence); printf("sending frame. sequence number: %d\n", sequence);
again: again:
len = write(s, &frame, sizeof(frame)); len = write(s, &frame, sizeof(frame));
if (len == -1) { if (len == -1) {
switch (errno) { switch (errno) {
@ -269,7 +270,7 @@ int main(int argc, char **argv)
{ "receive", no_argument, 0, 'r' }, { "receive", no_argument, 0, 'r' },
{ "verbose", no_argument, 0, 'v' }, { "verbose", no_argument, 0, 'v' },
{ "help", no_argument, 0, 'h' }, { "help", no_argument, 0, 'h' },
{ 0, 0, 0, 0}, { 0, 0, 0, 0 },
}; };
while ((opt = getopt_long(argc, argv, "ei:pq::rvh", long_options, NULL)) != -1) { while ((opt = getopt_long(argc, argv, "ei:pq::rvh", long_options, NULL)) != -1) {