]> xenbits.xensource.com Git - qemu-xen-4.0-testing.git/commit
check return value from read() and write() properly
authorIan Jackson <iwj@mariner.uk.xensource.com>
Wed, 13 Feb 2008 16:24:30 +0000 (16:24 +0000)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Mon, 12 May 2008 11:16:23 +0000 (12:16 +0100)
commita5975c8e7180095f786ac293c07b320185a25b4b
treefef5557747363459230b641d7908036b99ea261e
parentff347fdd3f33e42e91db49904af733082f97d775
check return value from read() and write() properly

The system calls read and write may return less than the whole amount
requested for a number of reasons.  So the idioms
   if (read(fd, &object, sizeof(object)) != sizeof(object)) goto fail;
and even worse
   if (read(fd, &object, sizeof(object)) < 0) goto fail;
are wrong.  Additionally, read and write may sometimes return EINTR on
some systems so interruption is not desired or expected a loop is
needed.
26 files changed:
Makefile
block-bochs.c
block-cloop.c
block-cow.c
block-dmg.c
block-parallels.c
block-qcow.c
block-raw-posix.c
block-vmdk.c
block-vpc.c
block-vvfat.c
darwin-user/machload.c
dyngen.c
elf_ops.h
hw/pc.c
linux-user/elfload.c
linux-user/linuxload.c
loader.c
osdep.c
osdep.h
tests/hello-arm.c
tests/linux-test.c
tests/qruncom.c
tests/testthread.c
usb-linux.c
vl.c