qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] Re: [PATCH] check return value from read() and write() prop


From: Ian Jackson
Subject: [Qemu-devel] Re: [PATCH] check return value from read() and write() properly
Date: Wed, 6 Feb 2008 17:14:20 +0000

iwj writes ("[PATCH] 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.
> 
> In the attached patch I introduce two new pairs of functions:

I think this fix should be applied because it corrects bugs which
might conceivably data loss.

Thanks,
Ian.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]