Subject: Re: [TCP] IPV6 : Change a divide into a right shift in tcp_v6_send_ack()

From: Eric Dumazet <[email-masked]>
Date: Fri, 21 Dec 2007 08:39:24 +0100

YOSHIFUJI Hideaki / 吉藤英明 a écrit :
> In article <[email-masked]> (at Fri, 21 Dec 2007 08:06:32 +0100), Eric Dumazet <[email-masked]> says:
> 
>> YOSHIFUJI Hideaki / 吉藤英明 a écrit :
>>> In article <[email-masked]> (at Fri, 21 Dec 2007 07:03:58 +0100), Eric Dumazet <[email-masked]> says:
>>>
>>>> Because tot_len is signed in tcp_v6_send_ack(), tot_len/4 forces compiler
>>>> to emit an integer divide, while we can help it to use a right shift,
>>>> less expensive.
>>> Are you really sure?
>>> At least, gcc-4.1.2-20061115 (debian) does not make any difference.
>>>
>>> And, IMHO, because shift for signed variable is fragile, so we should
>>> avoid using it.
>>>
>> Yes I am sure, but maybe you are on x86_64 ?
>>
>> gcc-4.2.2 on x86
> 
> I'm on gcc-4.1.2 20061115 (prerelease) (Debian 4.1.1-21), on x86 (i686).
> Maybe compiler difference?!
> 
>> If you think tot_len can be negative, I understand you can be against this 
>> patch. But I am sure it's allways > 0, even if I am a total ipv6 newbie :)
> 
> Okay, anyway, I'll convert them to unsigned int, which is more
> appropriate.

I didnt chose this path, because David was against changing some fields from 
'int' to 'unsigned'. If you look in other parts of networking, we have many >> 
1 or >> 2 already there.