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] [day] [month] [year] [list]
Message-ID: <265df0fd-7427-45d8-85fd-a487baf1521d@wanadoo.fr>
Date: Mon, 22 Dec 2025 12:28:01 +0100
From: Christophe JAILLET <christophe.jaillet@...adoo.fr>
To: Alison Schofield <alison.schofield@...el.com>
Cc: Davidlohr Bueso <dave@...olabs.net>,
 Jonathan Cameron <jonathan.cameron@...wei.com>,
 Dave Jiang <dave.jiang@...el.com>, Vishal Verma <vishal.l.verma@...el.com>,
 Ira Weiny <ira.weiny@...el.com>, Dan Williams <dan.j.williams@...el.com>,
 linux-kernel@...r.kernel.org, kernel-janitors@...r.kernel.org,
 linux-cxl@...r.kernel.org
Subject: Re: [PATCH] cxl: Slightly simplify emit_target_list()

Le 22/12/2025 à 04:52, Alison Schofield a écrit :
> On Sun, Dec 21, 2025 at 03:15:04PM +0100, Christophe JAILLET wrote:
>> sysfs_emit_at() never returns a negative error code. It returns 0 or the
>> number of characters written in the buffer.
>>
>> Remove the useless test. This simplifies the logic and saves a few lines of
>> code.
>>
>> Signed-off-by: Christophe JAILLET <christophe.jaillet@...adoo.fr>
>> ---
>>   drivers/cxl/core/port.c | 10 ++++------
>>   1 file changed, 4 insertions(+), 6 deletions(-)
>>
>> diff --git a/drivers/cxl/core/port.c b/drivers/cxl/core/port.c
>> index fef3aa0c6680..b77c1600beaa 100644
>> --- a/drivers/cxl/core/port.c
>> +++ b/drivers/cxl/core/port.c
>> @@ -151,7 +151,7 @@ static ssize_t emit_target_list(struct cxl_switch_decoder *cxlsd, char *buf)
>>   {
>>   	struct cxl_decoder *cxld = &cxlsd->cxld;
>>   	ssize_t offset = 0;
>> -	int i, rc = 0;
>> +	int i;
>>   
>>   	for (i = 0; i < cxld->interleave_ways; i++) {
>>   		struct cxl_dport *dport = cxlsd->target[i];
>> @@ -162,11 +162,9 @@ static ssize_t emit_target_list(struct cxl_switch_decoder *cxlsd, char *buf)
>>   
>>   		if (i + 1 < cxld->interleave_ways)
>>   			next = cxlsd->target[i + 1];
>> -		rc = sysfs_emit_at(buf, offset, "%d%s", dport->port_id,
>> -				   next ? "," : "");
>> -		if (rc < 0)
>> -			return rc;
>> -		offset += rc;
>> +		offset += sysfs_emit_at(buf, offset, "%d%s",
>> +					dport->port_id,
>> +					next ? "," : "");
>>   	}
>>   
>>   	return offset;
> 
> Can this can be cleaned up further at the target_list_show() call
> site which also checks for an impossible rc < 0 (twice).

I missed that, sorry.

target_list_show() only add a guard() and a trailing \n.
Maybe, both function could be merged.

Is it ok for you  this way ?

CJ

> 
> 
> 
>> -- 
>> 2.52.0
>>
> 
> 


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ