yyyy@xxxxxxxxxxxxx (Nick Maclaren) wrote on 17.08.00 in
<yyyyyyyyyyyyyyyyy@xxxxxxxxxxxxxxxxxxx>:
> Virtually EVERY serious Unix program written in K&R C or C90 will
> be broken if size_t/ptrdiff_t are larger than long/unsigned long.
> The breakages due to off_t exceeding long were such that I could
> see how to fix most of them (not always trivially), but I don't
> even know how I would START fixing many of those that would be
> broken by size_t exceeding unsigned long! In some cases, it
> would probably be easier to rewrite from the specification.
I might add that I was involved in fixing one of the Linux fdisk programs
(I *think* it was cfdisk) to work with 64 bit file offsets (to support
disks larger than 4G, which were just becoming common). I sent the
maintainer a description of what needed changing, *and he got it wrong*
(due to casting too late and loosing precision, IIRC[1]). I needed to send
an explicit patch. Even though I had essentially told him to copy the fix
from another Linux fdisk program which got it right.
Not only do programs break, people have trouble understanding the issues
involved.
[1] Code somewhat similar to lseek(sector_number*512,...) to become (IIRC)
llseek(((long long)sector_number)*512,...) was instead written
something like llseek((long long)(sector_number*512)).
Note that sector numbers did *not* grow over 32 bit (2TB disk size
limit), because the partition table just doesn't have more space for
sector numbers.
MfG Kai
|