[Libvir] take 2 [Re: write(2) may write less than the total requested

2008-02-20 Thread Jim Meyering
Daniel Veillard [EMAIL PROTECTED] wrote: 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) !=

Re: [Libvir] take 2 [Re: write(2) may write less than the total requested

2008-02-20 Thread Mark McLoughlin
On Wed, 2008-02-20 at 16:42 +0100, Jim Meyering wrote: If I do as you suggest and move the safewrite definition into util.h, and make it static inline, then both problems go away. Make sure to try and build this with gcc-4.3.0 - remember that we un-inlined xstrtol() because of:

Re: [Libvir] take 2 [Re: write(2) may write less than the total requested

2008-02-20 Thread Jim Paris
Hi Jim, comments inline Jim Meyering wrote: diff --git a/proxy/libvirt_proxy.c b/proxy/libvirt_proxy.c index d96d3db..a22ba6c 100644 --- a/proxy/libvirt_proxy.c +++ b/proxy/libvirt_proxy.c @@ -2,7 +2,7 @@ * proxy_svr.c: root suid proxy server for Xen access to APIs with no *

Re: [Libvir] take 2 [Re: write(2) may write less than the total requested

2008-02-20 Thread Jim Meyering
Mark McLoughlin [EMAIL PROTECTED] wrote: On Wed, 2008-02-20 at 16:42 +0100, Jim Meyering wrote: If I do as you suggest and move the safewrite definition into util.h, and make it static inline, then both problems go away. Make sure to try and build this with gcc-4.3.0 - remember that we

Re: [Libvir] take 2 [Re: write(2) may write less than the total requested

2008-02-20 Thread Jim Meyering
Jim Paris [EMAIL PROTECTED] wrote: Jim Meyering wrote: ... Hi Jim, -retry: -ret = write(pollInfos[nr].fd, (char *) req, req-len); +ret = safewrite(pollInfos[nr].fd, (char *) req, req-len); if (ret 0) { Should this check (ret == req-len) instead? safewrite() will return an

Re: [Libvir] take 2 [Re: write(2) may write less than the total requested

2008-02-20 Thread Jim Paris
Jim Meyering wrote: It *could* perform that test, but I think it is slightly more maintainable (no duplication of that potentially nontrivial expression) and just as correct to check only ret 0. Not having the duplicated expression is certainly good, if it's correct to do so (and it seems