Re: [PATCH RFC 2/6] perf dso: Refactor dso_cache__read()

From: Jiri Olsa
Date: Mon Oct 28 2019 - 11:39:41 EST


On Fri, Oct 25, 2019 at 03:59:56PM +0300, Adrian Hunter wrote:

SNIP

> +}
>
> - return ret;
> +static struct dso_cache *dso_cache__find(struct dso *dso,
> + struct machine *machine,
> + u64 offset,
> + ssize_t *ret)
> +{
> + struct dso_cache *cache = __dso_cache__find(dso, offset);
> +
> + return cache ? cache : dso_cache__populate(dso, machine, offset, ret);
> }
>
> static ssize_t dso_cache_read(struct dso *dso, struct machine *machine,
> u64 offset, u8 *data, ssize_t size)
> {
> struct dso_cache *cache;
> + ssize_t ret = 0;
>
> - cache = dso_cache__find(dso, offset);
> - if (cache)
> - return dso_cache__memcpy(cache, offset, data, size);
> - else
> - return dso_cache__read(dso, machine, offset, data, size);
> + cache = dso_cache__find(dso, machine, offset, &ret);
> + if (!cache)
> + return ret;

why not use the ERR_* macros to get error through the pointer
instead of adding extra argument?

jirka


> +
> + return dso_cache__memcpy(cache, offset, data, size);
> }
>
> /*
> --
> 2.17.1
>