Re: [PATCH] Fix 32-bit overflow in Divesoft Freedom time handling

2015-10-03 Thread Dirk Hohndel
On Sat, Oct 03, 2015 at 09:38:10AM +0200, Anton Lundin wrote: > On 02 October, 2015 - Linus Torvalds wrote: > > > Commit 31fb2e4c62ab ("Avoid possible sign extension") handled the > > problem when a "unsigned char" is shifted 24 bits left, and becomes a > > "signed int". By casting the result to

Re: [PATCH] Fix 32-bit overflow in Divesoft Freedom time handling

2015-10-03 Thread Linus Torvalds
On Oct 3, 2015 7:03 AM, "Dirk Hohndel" wrote: > > Which then means that the old code was actually correct and the fix and > the fix of the fix were actually wrong? Well, the final add (to convert from 2000-based numbers to 1970-based ones) should still be done in timestamp_t.

Re: [PATCH] Fix 32-bit overflow in Divesoft Freedom time handling

2015-10-03 Thread Anton Lundin
On 03 October, 2015 - Anton Lundin wrote: > On 02 October, 2015 - Linus Torvalds wrote: > > > Commit 31fb2e4c62ab ("Avoid possible sign extension") handled the > > problem when a "unsigned char" is shifted 24 bits left, and becomes a > > "signed int". By casting the result to uint32_t, that

Re: [PATCH] Fix 32-bit overflow in Divesoft Freedom time handling

2015-10-03 Thread Thiago Macieira
On Saturday 03 October 2015 09:38:10 Anton Lundin wrote: > The root bug was mine. Another one of C's wonderful things that i didn't > know about. Yeah... unsigned short us = 0x; unsigned u = 0x; us * us;// this is undefined behaviour u *

Re: [PATCH] Fix 32-bit overflow in Divesoft Freedom time handling

2015-10-03 Thread Anton Lundin
On 02 October, 2015 - Linus Torvalds wrote: > Commit 31fb2e4c62ab ("Avoid possible sign extension") handled the > problem when a "unsigned char" is shifted 24 bits left, and becomes a > "signed int". By casting the result to uint32_t, that signed case won't > happen. > The root bug was mine.

[PATCH] Fix 32-bit overflow in Divesoft Freedom time handling

2015-10-02 Thread Linus Torvalds
From: Linus Torvalds <torva...@linux-foundation.org> Date: Fri, 2 Oct 2015 21:26:32 -0400 Subject: [PATCH] Fix 32-bit overflow in Divesoft Freedom time handling Commit 31fb2e4c62ab ("Avoid possible sign extension") handled the problem when a "unsigned char" is shifted

Re: [PATCH] Fix 32-bit overflow in Divesoft Freedom time handling

2015-10-02 Thread Dirk Hohndel
> From: Linus Torvalds <torva...@linux-foundation.org> > Date: Fri, 2 Oct 2015 21:26:32 -0400 > Subject: [PATCH] Fix 32-bit overflow in Divesoft Freedom time handling > > Commit 31fb2e4c62ab ("Avoid possible sign extension") handled the > problem when a "