On Wed, Feb 20, 2008 at 02:53:49PM +0100, Jim Meyering wrote:
Use safewrite in place of write, in many cases.
And add "make syntax-check" rules to ensure no new uses sneak in.
There are many uses of write like this:
if (write (fd, xml, towrite) != towrite)
return -1;
The problem is that the syscall can succeed, yet write less than
the requested number of bytes, so the caller should retry
rather than simply failing.
agreed using safewrite is a good idea, +1
This patch changes most of them to use util.c's safewrite
wrapper,
which encapsulates the process. Also, there were a few cases in
which the retry loop was open-coded, and I replaced those, too.
However, there remain invalid uses of write in both virsh.c and
console.c. I would have replaced those, too, but util.c isn't
linked with them, so it would have made this change more involved.
xend_internal.c has one use, but it's ok, and not easily replaced.
maybe for case outside of the library adding a copy of safewrite
in virsh.c would be a good way to do this while keeping the code
consistent. The duplication of that small function whould not
be a real problem IMHO
Daniel
--
Red Hat Virtualization group
http://redhat.com/virtualization/
Daniel Veillard | virtualization library
http://libvirt.org/
veillard(a)redhat.com | libxml GNOME XML XSLT toolkit
http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine
http://rpmfind.net/