Re: [PATCH 5/5] Lib: sort.h: replace int size with size_t size in the swap function

From: Andrey Abramov
Date: Mon Apr 01 2019 - 14:14:52 EST


01.04.2019, 21:02, "Vineet Gupta" <vineet.gupta1@xxxxxxxxxxxx>:
> On 4/1/19 7:46 AM, David Laight wrote:
>> ÂFrom: gregkh@xxxxxxxxxxxxxxxxxxx
>>> ÂSent: 31 March 2019 11:54
>> Â...
>>> ÂYes, "int" is a very nice variable for "size", you need to explain why
>>> Âit is better to use size_t here please.
>> ÂActually, on x86_64 you probably want 'unsigned int' to avoid the
>> Âcompiler having to generate a sign-extending register move if the
>> Âvalue is ever used in a 64bit expression (eg an address calculation).
>
> Thats likely true for non x86 arches too (for certain on ARC). That is also the
> reason I dislike "bool", despite its "software engineering" benefits. Per ARC ABI
> (and likely others too) it is signed 8 bits and any use thereof, requires the
> compiler to generate an additional EXTB instruction to promote to 32-bit int with
> sign extension before using the value.
>
> -Vineet

George Spelvin wrote "So how about *deleting* the parameter instead?
That simplifies everything.", and he is right,
so I am just going to completely remove it.

Any objections?

--
With Best Regards,
Andrey Abramov