]> rtime.felk.cvut.cz Git - can-benchmark.git/commitdiff
Fix warnings in latester when compiled with -Wall
authorMichal Sojka <sojkam1@fel.cvut.cz>
Mon, 13 Jan 2014 13:50:55 +0000 (14:50 +0100)
committerMichal Sojka <sojkam1@fel.cvut.cz>
Mon, 13 Jan 2014 13:50:55 +0000 (14:50 +0100)
latester/latester.c

index 2e8f6e31eb9854d4fde58a39d490e9530b820f8f..67e1dcb1f6d17ede19d5c02c4c97bba238f46945 100644 (file)
@@ -4,6 +4,7 @@
 /* License: GPLv2                                                             */
 /*******************************************************************************/
 
+#define _GNU_SOURCE
 #include <ctype.h>
 #include <errno.h>
 #include <error.h>
@@ -161,6 +162,8 @@ static inline char *tstamp_str(const void *ctx, struct timespec *tstamp)
                               tstamp->tv_sec, tstamp->tv_nsec/1000);
 }
 
+int timespec_subtract (struct timespec *result, struct timespec *x, struct timespec *yy);
+
 void msg_info_print(FILE *f, struct msg_info *mi)
 {
        struct timespec diff;
@@ -291,7 +294,7 @@ static inline int sock_get_if_index(int s, const char *if_name)
        return ifr.ifr_ifindex;
 }
 
-static inline get_tstamp(struct timespec *ts)
+static inline void get_tstamp(struct timespec *ts)
 {
        clock_gettime(CLOCK_REALTIME, ts);
 }
@@ -300,7 +303,7 @@ static inline get_tstamp(struct timespec *ts)
 int trace_fd = -1;
 int marker_fd = -1;
 
-int init_ftrace()
+void init_ftrace()
 {
 #ifdef FTRACE
        char *debugfs;
@@ -402,7 +405,7 @@ int send_frame(int socket)
        return ret;
 }
 
-static inline send_and_check(int s)
+static inline void send_and_check(int s)
 {
        int ret;
        ret = send_frame(s);
@@ -480,9 +483,12 @@ void receive(int s, struct can_frame *frame, struct timespec *ts_kern, struct ti
             cmsg && (cmsg->cmsg_level == SOL_SOCKET);
             cmsg = CMSG_NXTHDR(&msg,cmsg)) {
                if (cmsg->cmsg_type == SO_TIMESTAMPNS)
-                       *ts_kern = *(struct timespec *)CMSG_DATA(cmsg);
-               else if (cmsg->cmsg_type == SO_RXQ_OVFL)
-                       dropcnt += *(__u32 *)CMSG_DATA(cmsg);
+                       memcpy(ts_kern, CMSG_DATA(cmsg), sizeof(struct timespec));
+               else if (cmsg->cmsg_type == SO_RXQ_OVFL) {
+                       uint32_t ovfl;
+                       memcpy(&ovfl, CMSG_DATA(cmsg), sizeof(ovfl));
+                       dropcnt += ovfl;
+               }
        }
 
 }
@@ -494,7 +500,7 @@ void process_tx(int s)
 
 void process_on_wire_rx(int s)
 {
-       struct timespec ts_kern, ts_user, ts_diff;
+       struct timespec ts_kern, ts_user;
        struct can_frame frame;
        struct msg_info *mi;
        receive(s, &frame, &ts_kern, &ts_user);
@@ -509,7 +515,7 @@ void process_on_wire_rx(int s)
 
 void process_final_rx(int s)
 {
-       struct timespec ts_kern, ts_user, ts_diff;
+       struct timespec ts_kern, ts_user;
        struct can_frame frame;
        struct msg_info *mi;
        int ret;
@@ -536,7 +542,6 @@ void *measure_thread(void *arg)
        struct pollfd pfd[3];
        struct timespec timeout;
        struct sockaddr_can addr;
-       sigset_t set;
        int consecutive_timeouts = 0;
 
        MEMSET_ZERO(pfd);
@@ -642,7 +647,7 @@ void *measure_thread(void *arg)
                                }
                        }
                        if (pfd[i].revents & ~POLLIN)
-                               error(1, 0, "Unexpected pfd[%d].revents: 0x%04x\n", pfd[i].revents);
+                               error(1, 0, "Unexpected pfd[%d].revents: 0x%04x\n", i, pfd[i].revents);
                }
        }
 
@@ -745,7 +750,6 @@ void print_progress()
 int main(int argc, const char *argv[])
 {
        pthread_t thread;
-       sigset_t set;
        int ret, i;
 
        parse_options(argc, argv);