Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp3324935yba; Tue, 16 Apr 2019 09:05:26 -0700 (PDT) X-Google-Smtp-Source: APXvYqy47bLUIX3pELRqEDRqGMV9vtRD1mMvwiuM/0Pj8N+feLW24xADlT6GimSGVgxUdjEHC+Ci X-Received: by 2002:a63:4620:: with SMTP id t32mr76486046pga.363.1555430726016; Tue, 16 Apr 2019 09:05:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555430726; cv=none; d=google.com; s=arc-20160816; b=AbtPvMdjbTUAFgjc9CiUAvdwVsswuFJUokxDMSGrjVc4BUkXHm4nI8rq9EWkEUIDKC n4JovQhviDudColKfm1sZv0f9rgCBOWCJ6ikO43pkiCcwaJx3rEhRYB0nue7nCD8X8qC 2m5MxwhBfaqh6PpKpTOw/romW6B73mGqcmGBaY64nqoH0zrvGn8hR42r5ATIQ1EwWACq Nv6+HRcBz0+xUGkb+W4lhk0Zw17CEDcjR2jfZvJMsd47gQjx29rlBctQmMvFIgTV/V7C 69RvHoZ8jOzDEQa/KFCeN5kuviRLxY4+HSZSONYRd9dRAdYQhj+UpN1Jd9GVw+OfgYGU nOHg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=k9sJR0TenfX3V7AJHortRCgeyXjvGgzho6aH5wokMyI=; b=GEhnMvZP2k8wOHMFK/vlZnAoizrbGpxHrXP6VLJeFbHTYOdOsLkNuFKR4egRnt3IgT CIAo/cIq8jqgjBL4Tf0P6H9DO9GMzDS2hL+hP0YWe18LgqQ/iD6Uy1f1/H/TGIjtUoud p7rcnJ1IIkJMNxxA+Py3ZnGNF2bOxQ2gKTBW3ozzyNrco6dA4MPBL4toF02FYxZAb/M+ fV4FQx10fDmZrLOQwyMMYGNUAT7MOCkaioo4dR/xkF9UiNYlFVeNQkIwd6bWVH2YbUL9 bxfI2CqR9u5b+B0LfYxam203kBoQr6QLhLneZCofuMP9tZQ+ItpZz/0S+yBDoUtPy/1a N3BQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w125si51168652pfw.137.2019.04.16.09.05.09; Tue, 16 Apr 2019 09:05:26 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729939AbfDPQBs (ORCPT + 99 others); Tue, 16 Apr 2019 12:01:48 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56004 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729911AbfDPQBp (ORCPT ); Tue, 16 Apr 2019 12:01:45 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B553E7FDE9; Tue, 16 Apr 2019 16:01:44 +0000 (UTC) Received: from krava.brq.redhat.com (unknown [10.43.17.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id 698675D71A; Tue, 16 Apr 2019 16:01:42 +0000 (UTC) From: Jiri Olsa To: Arnaldo Carvalho de Melo Cc: lkml , Ingo Molnar , Namhyung Kim , Alexander Shishkin , Peter Zijlstra , Andi Kleen , Adrian Hunter , Song Liu , Alexei Starovoitov , Daniel Borkmann Subject: [PATCH 03/12] perf tools: Simplify dso_cache__read function Date: Tue, 16 Apr 2019 18:01:18 +0200 Message-Id: <20190416160127.30203-4-jolsa@kernel.org> In-Reply-To: <20190416160127.30203-1-jolsa@kernel.org> References: <20190416160127.30203-1-jolsa@kernel.org> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Tue, 16 Apr 2019 16:01:45 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org There's no need for the while loop now, also we can connect two (ret > 0) condition legs together. Link: http://lkml.kernel.org/n/tip-2vg28bak8euojuvq33cy2hl5@git.kernel.org Signed-off-by: Jiri Olsa --- tools/perf/util/dso.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c index 6baad22ec8a9..6fdff723e55a 100644 --- a/tools/perf/util/dso.c +++ b/tools/perf/util/dso.c @@ -822,25 +822,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 */ -- 2.17.2