lkml.org 
[lkml]   [2013]   [Nov]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 3/7] perf tools: Fine tune readn function
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


\
 
 \ /
  Last update: 2013-11-28 16:41    [W:0.109 / U:0.056 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site