All of lore.kernel.org
 help / color / mirror / Atom feed
From: Oliver Hartkopp <socketcan@hartkopp.net>
To: Yegor Yefremov <yegorslists@googlemail.com>, linux-can@vger.kernel.org
Subject: Re: [PATCH] canplayer: convert skipgap to unsigned long
Date: Fri, 10 Apr 2015 11:29:11 +0200	[thread overview]
Message-ID: <552797E7.9000304@hartkopp.net> (raw)
In-Reply-To: <1428613281-21827-1-git-send-email-yegorslists@googlemail.com>



On 09.04.2015 23:01, Yegor Yefremov wrote:
> 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.
>

Yes. And additionally

	skipgap = strtoul(optarg, NULL, 10);

should have pointed me to use unsigned long m)

Thanks Yegor!

Acked-by: Oliver Hartkopp <socketcan@hartkopp.net>

Regards,
Oliver

> Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
> ---
>   canplayer.c | 7 ++++---
>   1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/canplayer.c b/canplayer.c
> index f74668e..437ed4b 100644
> --- a/canplayer.c
> +++ b/canplayer.c
> @@ -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");
> @@ -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;
> @@ -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;
>

  reply	other threads:[~2015-04-10  9:29 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-09 21:01 [PATCH] canplayer: convert skipgap to unsigned long Yegor Yefremov
2015-04-10  9:29 ` Oliver Hartkopp [this message]
2015-04-10  9:33   ` Yegor Yefremov
2015-04-10  9:37     ` Oliver Hartkopp
2015-04-10  9:37       ` Yegor Yefremov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=552797E7.9000304@hartkopp.net \
    --to=socketcan@hartkopp.net \
    --cc=linux-can@vger.kernel.org \
    --cc=yegorslists@googlemail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.