coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] maint: remove useless (off_t) cast of lseek arg


From: Pádraig Brady
Subject: Re: [PATCH] maint: remove useless (off_t) cast of lseek arg
Date: Sun, 29 May 2011 00:23:54 +0100
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.8) Gecko/20100227 Thunderbird/3.0.3

On 28/05/11 22:47, Jim Meyering wrote:
> Jim Meyering wrote:
> 
>> These (off_t) casts are anachronistic.
>> They were useful in pre-ANSI-C days, i.e., before prototypes.
>> There are two remaining off_t casts, and neither appears useful:
>> (one is even inconsistently formatted, with no space after the ")" ;-)
>>
>>   src/shred.c:      if (offset > OFF_T_MAX - (off_t) soff)
>>   src/truncate.c:          if (ssize > OFF_T_MAX - (off_t)fsize)
>>
>> So I'll probably remove them, too.
> 
> Now I'm not so sure.
> soff is of type size_t and fsize is uintmax_t,
> each of which may be wider than off_t.
> I suspect that each of these trigger one of the warnings
> that we have not enabled.

Yes it will trigger -Wsign-compare which has helped
me find hard to spot bugs.  It will also cause a bug I
think when ssize is negative, as then it will be promoted
to a large positive number for the comparison.
The truncate-overflow test catches this change in behavior.

cheers,
Pádraig.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]