All of lore.kernel.org
 help / color / mirror / Atom feed
* [Gitorious] Activity: konrada updated merge request for k...
@ 2013-02-07 10:17 Gitorious
  2013-02-07 10:38 ` [PATCH] cangen: use long long in time computation for -g to support >2.1s Marc Kleine-Budde
  0 siblings, 1 reply; 6+ messages in thread
From: Gitorious @ 2013-02-07 10:17 UTC (permalink / raw)
  To: mkl



Hello bet-frogger,

One of your favorites has a new activity:
------------------------------------------------------------------------
konrada updated merge request for konradas-can-utils with can-utils.
The merge request is at https://gitorious.org/linux-can/can-utils/merge_requests/1
------------------------------------------------------------------------

You are receiving this email because you have chosen to be notified by
email whenever this favorite has new activity. You can manage your
favorite subscriptions at https://gitorious.org/favorites

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH] cangen: use long long in time computation for -g to support >2.1s
  2013-02-07 10:17 [Gitorious] Activity: konrada updated merge request for k Gitorious
@ 2013-02-07 10:38 ` Marc Kleine-Budde
  2013-02-07 10:41   ` Marc Kleine-Budde
  0 siblings, 1 reply; 6+ messages in thread
From: Marc Kleine-Budde @ 2013-02-07 10:38 UTC (permalink / raw)
  To: linux-can; +Cc: Konrad Anton, Marc Kleine-Budde

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);
 
 	/* recognize obviously missing commandline option */
 	if (id_mode == MODE_FIX && frame.can_id > 0x7FF && !extended) {
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] cangen: use long long in time computation for -g to support >2.1s
  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
  2013-02-07 11:04     ` Konrad Anton
  0 siblings, 1 reply; 6+ messages in thread
From: Marc Kleine-Budde @ 2013-02-07 10:41 UTC (permalink / raw)
  To: Marc Kleine-Budde; +Cc: linux-can, Konrad Anton

[-- 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 --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] cangen: use long long in time computation for -g to support >2.1s
  2013-02-07 10:41   ` Marc Kleine-Budde
@ 2013-02-07 11:04     ` Konrad Anton
  2013-02-07 12:57       ` Marc Kleine-Budde
  0 siblings, 1 reply; 6+ messages in thread
From: Konrad Anton @ 2013-02-07 11:04 UTC (permalink / raw)
  To: linux-can

Hello,

On 07.02.2013 11:41, Marc Kleine-Budde wrote:
> we're a bit oldschool and discuss the code on the
> linux-can@vger.kernel.org mailinglist. Feel free to subscribe.

Can you please put that information on the Gitorious page for the next 
casual committer?


>>   	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".

gap is a double.
(gap * 1000000) will cause 1000000 to be converted to intermediate 
temp1 of type double,
temp1 will be truncated to long long temp2, losing its decimals,
temp2 will be moduloed by 1000000000ll in a long-long mod operation, 
giving temp3.
temp3 will be truncated to as many bits as long has, and stored in long 
tv_nsec.

I think it is safe.

--Konrad



-- 
------------------------------------------------------------------------
Konrad Anton
awinia gmbh, Software Consulting and Development
Max-Josef-Metzger-Str. 2, D-79111 Freiburg
Tel. +49 761 52 07 449 19
Fax. +49 761 52 07 449 10
EMail: konrad.anton@awinia.de
Handelsregister Nr.: HRB 706296, eingetragen beim Amtsgericht Freiburg
USt.-IdNr.: DE 275018159
Geschäftsführer: Marc Gossweiler, Bernd Wiedle
------------------------------------------------------------------------

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] cangen: use long long in time computation for -g to support >2.1s
  2013-02-07 11:04     ` Konrad Anton
@ 2013-02-07 12:57       ` Marc Kleine-Budde
       [not found]         ` <5113A525.2030208@awinia.de>
  0 siblings, 1 reply; 6+ messages in thread
From: Marc Kleine-Budde @ 2013-02-07 12:57 UTC (permalink / raw)
  To: Konrad Anton; +Cc: linux-can

[-- Attachment #1: Type: text/plain, Size: 1646 bytes --]

On 02/07/2013 12:04 PM, Konrad Anton wrote:
> Hello,
> 
> On 07.02.2013 11:41, Marc Kleine-Budde wrote:
>> we're a bit oldschool and discuss the code on the
>> linux-can@vger.kernel.org mailinglist. Feel free to subscribe.
> 
> Can you please put that information on the Gitorious page for the next
> casual committer?
> 
> 
>>>       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".
> 
> gap is a double.
> (gap * 1000000) will cause 1000000 to be converted to intermediate temp1
> of type double,
> temp1 will be truncated to long long temp2, losing its decimals,
> temp2 will be moduloed by 1000000000ll in a long-long mod operation,
> giving temp3.
> temp3 will be truncated to as many bits as long has, and stored in long
> tv_nsec.
> 
> I think it is safe.

Thanks for the details. Looks good. Can I add your Signed-off-by[1] to
the patch?

Marc
[1]
http://lxr.free-electrons.com/source/Documentation/SubmittingPatches#L298
-- 
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 --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] cangen: use long long in time computation for -g to support >2.1s
       [not found]         ` <5113A525.2030208@awinia.de>
@ 2013-02-07 13:02           ` Marc Kleine-Budde
  0 siblings, 0 replies; 6+ messages in thread
From: Marc Kleine-Budde @ 2013-02-07 13:02 UTC (permalink / raw)
  To: Konrad Anton

[-- Attachment #1: Type: text/plain, Size: 613 bytes --]

On 02/07/2013 01:59 PM, Konrad Anton wrote:
> On 07.02.2013 13:57, Marc Kleine-Budde wrote:
> 
>>
>> Thanks for the details. Looks good. Can I add your Signed-off-by[1] to
>> the patch?
>>
>> Marc
>> [1]
>> http://lxr.free-electrons.com/source/Documentation/SubmittingPatches#L298
> 
> Yes.

Pushed to master.

Tnx,
Marc
-- 
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 --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2013-02-07 13:03 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
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

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.