summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorKan Liang <kan.liang@intel.com>2018-01-19 00:26:20 +0300
committerArnaldo Carvalho de Melo <acme@redhat.com>2018-02-15 15:52:49 +0300
commit189f2cc91f9f2efef5d5f4dde43684c01b5f6f2f (patch)
treed24142a151f26c2bb5ee24bbe51a355253e73159 /tools
parent8872481bd04850b19e053dc579de5a11b83b16fc (diff)
downloadlinux-189f2cc91f9f2efef5d5f4dde43684c01b5f6f2f.tar.xz
perf mmap: Add new return value logic for perf_mmap__read_init()
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 <wangnan0@huawei.com> Signed-off-by: Kan Liang <kan.liang@intel.com> Acked-by: Jiri Olsa <jolsa@kernel.org> Cc: Andi Kleen <ak@linux.intel.com> Cc: Jin Yao <yao.jin@linux.intel.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Wang Nan <wangnan0@huawei.com> Link: http://lkml.kernel.org/r/1516310792-208685-6-git-send-email-kan.liang@intel.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/perf/util/mmap.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/tools/perf/util/mmap.c b/tools/perf/util/mmap.c
index c19a4e640e8e..38fa69dc635e 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;