]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
perf dso: Simplify dso_cache__read function
authorJiri Olsa <jolsa@kernel.org>
Wed, 8 May 2019 13:20:01 +0000 (15:20 +0200)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Tue, 28 May 2019 21:37:44 +0000 (18:37 -0300)
There's no need for the while loop now, also we can connect two (ret >
0) condition legs together.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Acked-by: Song Liu <songliubraving@fb.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Song Liu <songliubraving@fb.com>
Cc: Stanislav Fomichev <sdf@google.com>
Link: http://lkml.kernel.org/r/20190508132010.14512-4-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/dso.c

index 7734f50a6912a92ab40c066aa7d1958edc86b03d..1e6a045adb8ca7f3b7b7911b3352ad4814d4cea6 100644 (file)
@@ -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 */