• J
    Use safewrite in place of write, in many cases. · b59d9c85
    Jim Meyering 提交于
    Also 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.
    
    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.
    
    * Makefile.maint (sc_avoid_write): New rule, to avoid recurrence.
    * .x-sc_avoid_write: New file.  Record two legitimate exemptions.
    * qemud/qemud.c (sig_handler, qemudClientWriteBuf): Use safewrite, not write.
    * src/conf.c (__virConfWriteFile): Likewise.
    * src/qemu_conf.c (qemudSaveConfig, qemudSaveNetworkConfig): Likewise.
    * src/qemu_driver.c (qemudWaitForMonitor, qemudStartVMDaemon)
    (qemudVMData, PROC_IP_FORWARD): Likewise.
    * proxy/libvirt_proxy.c: Include "util.h".
    (proxyWriteClientSocket): Use safewrite.
    * src/test.c (testDomainSave, testDomainCoreDump): Likewise.
    * src/proxy_internal.c (virProxyWriteClientSocket): Likewise.
    * src/virsh.c: Include "util-lib.h".
    (vshOutputLogFile): Use safewrite.
    * src/console.c: Include "util-lib.h".
    (vshRunConsole): Use safewrite.
    b59d9c85
test.c 59.2 KB