From b55ca3688e84d51f68d5d0270f962b041b96f065 Mon Sep 17 00:00:00 2001 From: Michal Sojka Date: Fri, 17 Dec 2010 17:18:19 +0100 Subject: [PATCH] latester: Detect more errors --- latester/latester.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/latester/latester.c b/latester/latester.c index bdd539c..e4185b2 100644 --- a/latester/latester.c +++ b/latester/latester.c @@ -132,7 +132,7 @@ void sprint_canframe(char *buf , struct can_frame *cf, int sep) { } } -static inline struct msg_info *frame2info(struct can_frame *frame) +static inline uint16_t frame_index(struct can_frame *frame) { uint16_t idx; if (frame->can_dlc >= 2) { @@ -143,7 +143,12 @@ static inline struct msg_info *frame2info(struct can_frame *frame) error(1, 0, "%s error", __FUNCTION__); } - return &msg_infos[idx]; + return idx; +} + +static inline struct msg_info *frame2info(struct can_frame *frame) +{ + return &msg_infos[frame_index(frame)]; } static inline char *tstamp_str(const void *ctx, struct timespec *tstamp) @@ -597,13 +602,15 @@ void *measure_thread(void *arg) } pfd[0].revents = 0; - if (num_interfaces == 3 && pfd[1].revents != 0) { + if (num_interfaces == 3 && pfd[1].revents & POLLIN) { process_on_wire_rx(pfd[1].fd); pfd[1].revents = 0; } + if (num_interfaces == 3 && pfd[1].revents & ~POLLIN) + error(1, 0, "Unexpected pfd[1].revents: 0x%04x\n", pfd[1].revents); i = (num_interfaces == 2) ? 1 : 2; - if (pfd[i].revents != 0) { + if (pfd[i].revents & POLLIN) { consecutive_timeouts = 0; process_final_rx(pfd[i].fd); msg_in_progress--; @@ -613,6 +620,8 @@ void *measure_thread(void *arg) SEND(); } } + if (pfd[i].revents & ~POLLIN) + error(1, 0, "Unexpected pfd[%d].revents: 0x%04x\n", pfd[i].revents); } } -- 2.39.2