From: Ian Rogers <irogers@xxxxxxxxxx> [ Upstream commit 05be17eed774aaf56f6b1e12714325ca3a266c04 ] Switch from returning -1 to -errno so that callers can determine types of failure. Reviewed-by: Namhyung Kim <namhyung@xxxxxxxxxx> Signed-off-by: Ian Rogers <irogers@xxxxxxxxxx> Acked-by: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx> Cc: Adrian Hunter <adrian.hunter@xxxxxxxxx> Cc: Alexander Shishkin <alexander.shishkin@xxxxxxxxxxxxxxx> Cc: Andi Kleen <ak@xxxxxxxxxxxxxxx> Cc: Athira Rajeev <atrajeev@xxxxxxxxxxxxxxxxxx> Cc: Ben Gainey <ben.gainey@xxxxxxx> Cc: Colin Ian King <colin.i.king@xxxxxxxxx> Cc: Dominique Martinet <asmadeus@xxxxxxxxxxxxx> Cc: Ilkka Koskinen <ilkka@xxxxxxxxxxxxxxxxxxxxxx> Cc: Ingo Molnar <mingo@xxxxxxxxxx> Cc: James Clark <james.clark@xxxxxxxxxx> Cc: Jiri Olsa <jolsa@xxxxxxxxxx> Cc: Kan Liang <kan.liang@xxxxxxxxxxxxxxx> Cc: Mark Rutland <mark.rutland@xxxxxxx> Cc: Oliver Upton <oliver.upton@xxxxxxxxx> Cc: Paran Lee <p4ranlee@xxxxxxxxx> Cc: Peter Zijlstra <peterz@xxxxxxxxxxxxx> Cc: Steinar H. Gunderson <sesse@xxxxxxxxxx> Cc: Steven Rostedt (VMware) <rostedt@xxxxxxxxxxx> Cc: Thomas Falcon <thomas.falcon@xxxxxxxxx> Cc: Weilin Wang <weilin.wang@xxxxxxxxx> Cc: Yang Jihong <yangjihong@xxxxxxxxxxxxx> Cc: Yang Li <yang.lee@xxxxxxxxxxxxxxxxx> Cc: Ze Gao <zegao2021@xxxxxxxxx> Cc: Zixian Cai <fzczx123@xxxxxxxxx> Cc: zhaimingbing <zhaimingbing@xxxxxxxxxxxxxxxxxxxx> Link: https://lore.kernel.org/r/20241118225345.889810-3-irogers@xxxxxxxxxx Signed-off-by: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx> Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx> --- tools/lib/api/fs/fs.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/lib/api/fs/fs.c b/tools/lib/api/fs/fs.c index 4cc69675c2a9a..234c882f9029c 100644 --- a/tools/lib/api/fs/fs.c +++ b/tools/lib/api/fs/fs.c @@ -323,7 +323,7 @@ int filename__read_int(const char *filename, int *value) int fd = open(filename, O_RDONLY), err = -1; if (fd < 0) - return -1; + return -errno; if (read(fd, line, sizeof(line)) > 0) { *value = atoi(line); @@ -341,7 +341,7 @@ static int filename__read_ull_base(const char *filename, int fd = open(filename, O_RDONLY), err = -1; if (fd < 0) - return -1; + return -errno; if (read(fd, line, sizeof(line)) > 0) { *value = strtoull(line, NULL, base); @@ -428,7 +428,7 @@ int filename__write_int(const char *filename, int value) char buf[64]; if (fd < 0) - return err; + return -errno; sprintf(buf, "%d", value); if (write(fd, buf, sizeof(buf)) == sizeof(buf)) -- 2.39.5