On Thu, Sep 21, 2017 at 11:49 AM, Torsten Bögershausen <tbo...@web.de> wrote:
> On 2017-09-21 18:46, Ramsay Jones wrote:
>>
>> Signed-off-by: Ramsay Jones <ram...@ramsayjones.plus.com>
>> ---
>>  git-compat-util.h | 6 ++++--
>>  1 file changed, 4 insertions(+), 2 deletions(-)
>>
>> diff --git a/git-compat-util.h b/git-compat-util.h
>> index 9bc15b036..cedad4d58 100644
>> --- a/git-compat-util.h
>> +++ b/git-compat-util.h
>> @@ -898,9 +898,11 @@ static inline char *xstrdup_or_null(const char *str)
>>
>>  static inline size_t xsize_t(off_t len)
>>  {
>> -     if (len > (size_t) len)
>> +     size_t size = (size_t) len;
>> +
>> +     if (len != (off_t) size)
>>               die("Cannot handle files this big");
>> -     return (size_t)len;
>> +     return size;
>
> Hm, can someone help me out ?
> Why is the cast not needed ?

Because 'size' is already size_t,
(cast was done in first line of the function:
    size_t size = (size_t) len;
), previously we cast len multiple times,
now we cast it once and use size thereafter.

>
>>  }
>>
>>  __attribute__((format (printf, 3, 4)))
>>
>

Reply via email to