Re: [PATCH 3/7] perf tools: Fine tune readn function

From: David Ahern
Date: Thu Nov 28 2013 - 10:19:58 EST


On 11/28/13, 3:30 AM, Jiri Olsa wrote:
@@ -151,21 +152,26 @@ unsigned long convert_unit(unsigned long value, char *unit)
return value;
}

+/*
+ * Read exactly 'n' bytes or return an error.
+ */
ssize_t readn(int fd, void *buf, size_t n)
{
void *buf_start = buf;
+ size_t left = n;

- while (n) {
- ssize_t ret = read(fd, buf, n);
+ while (left) {
+ ssize_t ret = read(fd, buf, left);

if (ret <= 0)
return ret;

handle EINTR errors? no need to fail readn if the system call is interrupted.

David
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/