[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: bin/48183: Example in man write(2) causes endless loop
The following reply was made to PR bin/48183; it has been noted by GNATS.
From: David Laight <david%l8s.co.uk@localhost>
Subject: Re: bin/48183: Example in man write(2) causes endless loop
Date: Thu, 5 Sep 2013 08:10:23 +0100
On Wed, Sep 04, 2013 at 11:30:00PM +0000, manuel%bsdstammtisch.at@localhost
> >Number: 48183
> >Category: bin
> >Synopsis: Example in man write(2) causes endless loop
> The manpage of pread says:
> Proper loops should use
> while ((nr = write(fd, buf, sizeof(buf))) != -1 && nr != 0)
> which is clearly an endless loop. Say nr = 512 and the write is
> successful, then 512 != -1 && n1 !=0 is true.
That whole section is fud.
It would only ever be a problem if the program had a buffer large enough.
That is a 2GB buffer on a system with 32bit size_t!
The application would also know that it was doing very large writes.
In most programs the write() calls are small (relative to size_t).
I suspect it is only a problem for systems with 16bit size_t and 32bit ptr.
The 'partial write' support would be more useful - especially for writev().
David Laight: david%l8s.co.uk@localhost
Main Index |
Thread Index |