From: Marc Kleine-Budde <mkl@pengutronix.de>
To: Marc Kleine-Budde <mkl@pengutronix.de>
Cc: linux-can@vger.kernel.org, Konrad Anton <konrad.anton@awinia.de>
Subject: Re: [PATCH] cangen: use long long in time computation for -g to support >2.1s
Date: Thu, 07 Feb 2013 11:41:56 +0100 [thread overview]
Message-ID: <511384F4.703@pengutronix.de> (raw)
In-Reply-To: <1360233489-14471-1-git-send-email-mkl@pengutronix.de>
[-- Attachment #1: Type: text/plain, Size: 1654 bytes --]
Hello Konrad,
we're a bit oldschool and discuss the code on the
linux-can@vger.kernel.org mailinglist. Feel free to subscribe.
On 02/07/2013 11:38 AM, Marc Kleine-Budde wrote:
> From: Konrad Anton <konrad.anton@awinia.de>
>
> The computation of nanosleep times for the "-g" option to cangen.c (delay
> between sends) overflows when more than 2100ms are given.
>
> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
> ---
>
> This is the pull gitorious pull reqeust transformed into a standard git one. :)
>
> Marc
>
> cangen.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/cangen.c b/cangen.c
> index 7518c12..db4c803 100644
> --- a/cangen.c
> +++ b/cangen.c
> @@ -269,7 +269,7 @@ int main(int argc, char **argv)
> }
>
> ts.tv_sec = gap / 1000;
> - ts.tv_nsec = ((int)(gap * 1000000)) % 1000000000;
> + ts.tv_nsec = (long)(((long long)(gap * 1000000)) % 1000000000ll);
What's going on here exactly?
gap is a double - Will it be converted into an int before multiplication
with 1000000? IIRC there is a difference between "gap * 1000000" and
"gap * 1000000.0". In the latter the multiplication is done in floating
point, because of the ".0".
Marc
>
> /* recognize obviously missing commandline option */
> if (id_mode == MODE_FIX && frame.can_id > 0x7FF && !extended) {
>
--
Pengutronix e.K. | Marc Kleine-Budde |
Industrial Linux Solutions | Phone: +49-231-2826-924 |
Vertretung West/Dortmund | Fax: +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686 | http://www.pengutronix.de |
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 263 bytes --]
next prev parent reply other threads:[~2013-02-07 10:42 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-02-07 10:17 [Gitorious] Activity: konrada updated merge request for k Gitorious
2013-02-07 10:38 ` [PATCH] cangen: use long long in time computation for -g to support >2.1s Marc Kleine-Budde
2013-02-07 10:41 ` Marc Kleine-Budde [this message]
2013-02-07 11:04 ` Konrad Anton
2013-02-07 12:57 ` Marc Kleine-Budde
[not found] ` <5113A525.2030208@awinia.de>
2013-02-07 13:02 ` Marc Kleine-Budde
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=511384F4.703@pengutronix.de \
--to=mkl@pengutronix.de \
--cc=konrad.anton@awinia.de \
--cc=linux-can@vger.kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).