Skip to content

Commit

Permalink
canplayer: convert skipgap to unsigned long
Browse files Browse the repository at this point in the history
The result of (last_log_tv.tv_sec - log_tv.tv_sec) is
unsigned long, so use labs() in order not to trim the
value to int. Make skipgap to unsigned long for the same
reason.

Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
Acked-by: Oliver Hartkopp <socketcan@hartkopp.net>
  • Loading branch information
yegorich committed Apr 10, 2015
1 parent 47fbe8f commit 5846246
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions canplayer.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ void print_usage(char *prg)
"send frames immediately)\n");
fprintf(stderr, " -g <ms> (gap in milli "
"seconds - default: %d ms)\n", DEFAULT_GAP);
fprintf(stderr, " -s <s> (skip gaps in "
fprintf(stderr, " -s <s> (skip gaps in "
"timestamps > 's' seconds)\n");
fprintf(stderr, " -x (disable local "
"loopback of sent CAN frames)\n");
Expand Down Expand Up @@ -241,7 +241,8 @@ int main(int argc, char **argv)
FILE *infile = stdin;
unsigned long gap = DEFAULT_GAP;
int use_timestamps = 1;
static int verbose, opt, delay_loops, skipgap;
static int verbose, opt, delay_loops;
static unsigned long skipgap;
static int loopback_disable = 0;
static int infinite_loops = 0;
static int loops = DEFAULT_LOOPS;
Expand Down Expand Up @@ -482,7 +483,7 @@ int main(int argc, char **argv)
/* test for logfile timestamps jumping backwards OR */
/* if the user likes to skip long gaps in the timestamps */
if ((last_log_tv.tv_sec > log_tv.tv_sec) ||
(skipgap && abs(last_log_tv.tv_sec - log_tv.tv_sec) > skipgap))
(skipgap && labs(last_log_tv.tv_sec - log_tv.tv_sec) > skipgap))
create_diff_tv(&today_tv, &diff_tv, &log_tv);

last_log_tv = log_tv;
Expand Down

0 comments on commit 5846246

Please sign in to comment.