From: Jiri Olsa Date: Wed, 8 May 2019 13:20:01 +0000 (+0200) Subject: perf dso: Simplify dso_cache__read function X-Git-Tag: v5.3-rc1~162^2~43^2~17 X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=commitdiff_plain;h=cacddfe7b0804752528e8100461266ec33dc6b64;p=linux.git perf dso: Simplify dso_cache__read function There's no need for the while loop now, also we can connect two (ret > 0) condition legs together. Signed-off-by: Jiri Olsa Acked-by: Song Liu Cc: Adrian Hunter Cc: Alexander Shishkin Cc: Andi Kleen Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Song Liu Cc: Stanislav Fomichev Link: http://lkml.kernel.org/r/20190508132010.14512-4-jolsa@kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c index 7734f50a6912..1e6a045adb8c 100644 --- a/tools/perf/util/dso.c +++ b/tools/perf/util/dso.c @@ -823,25 +823,20 @@ static ssize_t dso_cache__read(struct dso *dso, struct machine *machine, u64 offset, u8 *data, ssize_t size) { + u64 cache_offset = offset & DSO__DATA_CACHE_MASK; struct dso_cache *cache; struct dso_cache *old; ssize_t ret; - do { - u64 cache_offset = offset & DSO__DATA_CACHE_MASK; - - cache = zalloc(sizeof(*cache) + DSO__DATA_CACHE_SIZE); - if (!cache) - return -ENOMEM; - - ret = file_read(dso, machine, cache_offset, cache->data); + cache = zalloc(sizeof(*cache) + DSO__DATA_CACHE_SIZE); + if (!cache) + return -ENOMEM; + ret = file_read(dso, machine, cache_offset, cache->data); + if (ret > 0) { cache->offset = cache_offset; cache->size = ret; - } while (0); - - if (ret > 0) { old = dso_cache__insert(dso, cache); if (old) { /* we lose the race */