Em Mon, May 23, 2016 at 07:13:38AM +0000, Wang Nan escreveu:
> +++ b/tools/perf/util/evlist.c
> @@ -679,6 +679,38 @@ static struct perf_evsel 
> *perf_evlist__event2evsel(struct perf_evlist *evlist,
>       return NULL;
>  }
>  
> +static int perf_evlist__set_paused(struct perf_evlist *evlist, bool pause)
> +{
> +     int i;
> +
> +     for (i = 0; i < evlist->nr_mmaps; i++) {
> +             int fd = evlist->mmap[i].fd;
> +             int err;
> +
> +             if (fd < 0)
> +                     continue;
> +             err = ioctl(fd, PERF_EVENT_IOC_PAUSE_OUTPUT,
> +                         pause ? 1 : 0);
> +             if (err) {
> +                     err = (errno == 0 ? -EINVAL : -errno);
> +                     pr_err("Unable to pause output on %d: %s\n",
> +                            fd, strerror(-err));

I changed this to:
                if (err)
                        return err;

Like all other ioctl wrappers in evlist.c, i.e. usage model is the same
as with 'ioctl()': -1 indicates that it failed, if code using this
function wants to know more about the reason for the error, check errno.

Ah, we can't use 'pause' as a parameter name, that breaks the build on
Ubuntu 12.04 and other old glibc headers, I fixed that as well.

- Arnaldo

> +                     return err;
> +             }
> +     }
> +     return 0;

Reply via email to