lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZypTU7D3GUZ1APPQ@x1>
Date: Tue, 5 Nov 2024 14:18:11 -0300
From: Arnaldo Carvalho de Melo <acme@...nel.org>
To: Ian Rogers <irogers@...gle.com>
Cc: Peter Zijlstra <peterz@...radead.org>, Ingo Molnar <mingo@...hat.com>,
	Namhyung Kim <namhyung@...nel.org>,
	Mark Rutland <mark.rutland@....com>,
	Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
	Jiri Olsa <jolsa@...nel.org>,
	Adrian Hunter <adrian.hunter@...el.com>,
	Kan Liang <kan.liang@...ux.intel.com>,
	Athira Jajeev <atrajeev@...ux.vnet.ibm.com>,
	James Clark <james.clark@...aro.org>,
	Dominique Martinet <asmadeus@...ewreck.org>,
	Yang Li <yang.lee@...ux.alibaba.com>,
	Colin Ian King <colin.i.king@...il.com>,
	Yang Jihong <yangjihong@...edance.com>,
	"Steinar H. Gunderson" <sesse@...gle.com>,
	Oliver Upton <oliver.upton@...ux.dev>,
	Ilkka Koskinen <ilkka@...amperecomputing.com>,
	Ze Gao <zegao2021@...il.com>, Weilin Wang <weilin.wang@...el.com>,
	Ben Gainey <ben.gainey@....com>,
	zhaimingbing <zhaimingbing@...s.chinamobile.com>,
	Zixian Cai <fzczx123@...il.com>, Andi Kleen <ak@...ux.intel.com>,
	Paran Lee <p4ranlee@...il.com>,
	Thomas Falcon <thomas.falcon@...el.com>,
	linux-kernel@...r.kernel.org, linux-perf-users@...r.kernel.org,
	"Steven Rostedt (Google)" <rostedt@...dmis.org>
Subject: Re: [PATCH v2 1/6] tool api fs: Correctly encode errno for
 read/write open failures

On Sat, Nov 02, 2024 at 09:53:55AM -0700, Ian Rogers wrote:
> Switch from returning -1 to -errno so that callers can determine types
> of failure.

Acked-by: Arnaldo Carvalho de Melo <acme@...hat.com>

- Arnaldo
 
> Signed-off-by: Ian Rogers <irogers@...gle.com>
> ---
>  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 337fde770e45..edec23406dbc 100644
> --- a/tools/lib/api/fs/fs.c
> +++ b/tools/lib/api/fs/fs.c
> @@ -296,7 +296,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);
> @@ -314,7 +314,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);
> @@ -372,7 +372,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.47.0.199.ga7371fff76-goog

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ