Received: by 10.223.176.46 with SMTP id f43csp34253wra; Thu, 18 Jan 2018 13:31:04 -0800 (PST) X-Google-Smtp-Source: ACJfBoug7DEwg05mxBrWEMTq/nc+nFppYyx/sNqTHOTVPQRco4RbI0ITiUItyQV/EH0CmRL+n7KY X-Received: by 10.98.236.93 with SMTP id k90mr34423636pfh.35.1516311064771; Thu, 18 Jan 2018 13:31:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516311064; cv=none; d=google.com; s=arc-20160816; b=xkAv19PoB75VmsWDW7Z6drig7alXXXhAOgoIrx6M/8K+g20CYEKXDq5WlZ/mACkRqT kZvbhAphaMy5EToK9Ox9spQWMgmoDwF4F2H2xoaIlgksCq5hmPtpag4MUtC10eKDz19d B4n111MY1Q6eV+YpMI5YKGdLJxngadAytSIdivTKCVPonqPC7i8wfFuVhO3EAisLZSlH OwfzPe524oysGRR/7keNyo7IyBYppgYapia9+iaJXkyZbVqFqxYdbkkg7cpZEZjOvnrA Mb9ra6Ze/gfqcUAoZl8kdgnhzDa6FVUnQ4cPEe9IaGSqwBz1PTbaJFp/X1YOcZm9wnnq IR+Q== 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:arc-authentication-results; bh=+lB+BW3b6dyhpCoMbc/hRYDPbcPA8X62kyin17ZaPQc=; b=Pzr1YM2vvvZq6YNqZWZlpT4kf8MQ+9NrSTUqhYTKUn4hUWuxnK0cItBr+nD6g19H0i XgIkPGgLpec7NxrWFwYZwoSCW76/yppW22JLERi7lr527jSUde2ywVYXswGfHLFAuV9s bbrRdRrJ+IPAKRo3GoDe1nhE3K9ypPDvfzhGDfBxLM70eeAsZoqeVADnIEJvwyNYm6y1 WdN3wu3rhF+MNhZI9O+UDpRXqzkWlNWDKeuZVo6zMiyIjjJooXrJShe3+DijK3395VaC pUw0HVA3CoW6pAHIn4ukLWPnd5nfO6Ey6uLDxgB8dP+QMCjdKstorJF6THh7P/MYhGfj X5Gw== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n80si7605145pfi.380.2018.01.18.13.30.51; Thu, 18 Jan 2018 13:31:04 -0800 (PST) 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932457AbeARV2k (ORCPT + 99 others); Thu, 18 Jan 2018 16:28:40 -0500 Received: from mga04.intel.com ([192.55.52.120]:47419 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753986AbeARV1e (ORCPT ); Thu, 18 Jan 2018 16:27:34 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 18 Jan 2018 13:27:32 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,378,1511856000"; d="scan'208";a="11477230" Received: from otc-knm-01.jf.intel.com ([10.54.39.34]) by fmsmga008.fm.intel.com with ESMTP; 18 Jan 2018 13:27:32 -0800 From: kan.liang@intel.com To: acme@kernel.org, peterz@infradead.org, mingo@redhat.com, linux-kernel@vger.kernel.org Cc: wangnan0@huawei.com, jolsa@kernel.org, namhyung@kernel.org, ak@linux.intel.com, yao.jin@linux.intel.com, Kan Liang Subject: [PATCH V5 05/17] perf mmap: add new return value logic for perf_mmap__read_init() Date: Thu, 18 Jan 2018 13:26:20 -0800 Message-Id: <1516310792-208685-6-git-send-email-kan.liang@intel.com> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1516310792-208685-1-git-send-email-kan.liang@intel.com> References: <1516310792-208685-1-git-send-email-kan.liang@intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Kan Liang Improve the readability by using meaningful enum (-EAGAIN, -EINVAL and 0) to replace the three returning states (0, -1 and 1). Suggested-by: Wang Nan Signed-off-by: Kan Liang --- tools/perf/util/mmap.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tools/perf/util/mmap.c b/tools/perf/util/mmap.c index c19a4e6..38fa69d 100644 --- a/tools/perf/util/mmap.c +++ b/tools/perf/util/mmap.c @@ -282,7 +282,7 @@ int perf_mmap__read_init(struct perf_mmap *md, bool overwrite, *endp = overwrite ? old : head; if (*startp == *endp) - return 0; + return -EAGAIN; size = *endp - *startp; if (size > (unsigned long)(md->mask) + 1) { @@ -291,7 +291,7 @@ int perf_mmap__read_init(struct perf_mmap *md, bool overwrite, md->prev = head; perf_mmap__consume(md, overwrite); - return 0; + return -EAGAIN; } /* @@ -299,10 +299,10 @@ int perf_mmap__read_init(struct perf_mmap *md, bool overwrite, * most of data from it. */ if (overwrite_rb_find_range(data, md->mask, head, startp, endp)) - return -1; + return -EINVAL; } - return 1; + return 0; } int perf_mmap__push(struct perf_mmap *md, bool overwrite, @@ -316,8 +316,8 @@ int perf_mmap__push(struct perf_mmap *md, bool overwrite, int rc = 0; rc = perf_mmap__read_init(md, overwrite, &start, &end); - if (rc < 1) - return rc; + if (rc < 0) + return (rc == -EAGAIN) ? 0 : -1; size = end - start; -- 2.5.5