Re: [PATCH] iscsi: Simplify serial number comparisons

2011-04-12 Thread Nicholas A. Bellinger
On Thu, 2011-04-07 at 14:26 -0700, Mark Rustad wrote: Unsigned serial number comparison is very simple if you simply put the difference into a signed integer of the same size and then compare that value with zero. All the complexity and confusion fall away. Signed-off-by: Mark Rustad

Antw: [PATCH] iscsi: Simplify serial number comparisons

2011-04-08 Thread Ulrich Windl
Hi! I just wonder how safe the code is: Doesn't the difference of two unsigned ints give an unsigned value? The assigning an unsigned int to a signed int will definitely reduce the range... I feel that s32 diff = (s32) n1 - (s32) n2; also doesn't make the problem go away, unless ypou

Re: Antw: [PATCH] iscsi: Simplify serial number comparisons

2011-04-08 Thread Rustad, Mark D
Ulrich, On Apr 7, 2011, at 11:35 PM, Ulrich Windl wrote: I just wonder how safe the code is: Doesn't the difference of two unsigned ints give an unsigned value? The assigning an unsigned int to a signed int will definitely reduce the range... Actually, that isn't true. There are 2^32

Re: Antw: [PATCH] iscsi: Simplify serial number comparisons

2011-04-08 Thread Paul Koning
On Apr 8, 2011, at 1:22 PM, Rustad, Mark D wrote: Ulrich, On Apr 7, 2011, at 11:35 PM, Ulrich Windl wrote: I just wonder how safe the code is: Doesn't the difference of two unsigned ints give an unsigned value? The assigning an unsigned int to a signed int will definitely reduce the

Re: Antw: [PATCH] iscsi: Simplify serial number comparisons

2011-04-08 Thread Rustad, Mark D
On Apr 8, 2011, at 10:28 AM, Paul Koning wrote: On Apr 8, 2011, at 1:22 PM, Rustad, Mark D wrote: Ulrich, On Apr 7, 2011, at 11:35 PM, Ulrich Windl wrote: I just wonder how safe the code is: Doesn't the difference of two unsigned ints give an unsigned value? The assigning an

[PATCH] iscsi: Simplify serial number comparisons

2011-04-07 Thread Mark Rustad
Unsigned serial number comparison is very simple if you simply put the difference into a signed integer of the same size and then compare that value with zero. All the complexity and confusion fall away. Signed-off-by: Mark Rustad mark.d.rus...@intel.com --- include/scsi/iscsi_proto.h | 21