tool api fs: Correctly encode errno for read/write open failures
Sasha Levin
maintainerPATCH 1/1 tool api fs: Correctly encode errno for read/write open failures
From: Ian Rogers <[email protected]>
[ Upstream commit 05be17eed774aaf56f6b1e12714325ca3a266c04 ]
Switch from returning -1 to -errno so that callers can determine types of failure.
Reviewed-by Namhyung Kim <[email protected]>
Signed-off-by Ian Rogers <[email protected]>
Cc Adrian Hunter <[email protected]>
Cc Alexander Shishkin <[email protected]>
Cc Andi Kleen <[email protected]>
Cc Athira Rajeev <[email protected]>
Cc Ben Gainey <[email protected]>
Cc Colin Ian King <[email protected]>
Cc Dominique Martinet <[email protected]>
Cc Ilkka Koskinen <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc James Clark <[email protected]>
Cc Jiri Olsa <[email protected]>
Cc Kan Liang <[email protected]>
Cc Mark Rutland <[email protected]>
Cc Oliver Upton <[email protected]>
Cc Paran Lee <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Steinar H. Gunderson <[email protected]>
Cc Steven Rostedt (VMware) <[email protected]>
Cc Thomas Falcon <[email protected]>
Cc Weilin Wang <[email protected]>
Cc Yang Jihong <[email protected]>
Cc Yang Li <[email protected]>
Cc Ze Gao <[email protected]>
Cc Zixian Cai <[email protected]>
Cc zhaimingbing <[email protected]>
Signed-off-by Arnaldo Carvalho de Melo <[email protected]>
Signed-off-by Sasha Levin <[email protected]>
--- tools/lib/api/fs/fs.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
tools/lib/api/fs/fs.c +3 -3
@@ -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))
Signature · 1 line
2.39.5