Re: [PATCH] stream_to_pack: xread does not guarantee to read all requested bytes

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

 



Am 20.08.2013 17:16, schrieb Antoine Pelisse:
I was actually wondering when it's better to use xread() over
read_in_full() ? Considering that we don't know if xread() will read
the whole buffer or not, would it not be better to always use
read_in_full() ?

Of course, you know whether the whole buffer was filled: xread() returns the number of bytes read. Same for xwrite().

I guess there is a drawback to this, but I'm not
exactly sure what it is.

The disadvantage of read_in_full() is that it can happen that it reads data from the stream successfully, but then reports an error. In this case, the data read is lost.

Analogously, when write_in_full() writes (some) data successfully, but ultimately fails, you don't know how much was written successfully.

-- Hannes

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]