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: <26ca6aa2-1641-4809-8b75-5579931874bf@icloud.com>
Date: Tue, 17 Dec 2024 22:13:22 +0800
From: Zijun Hu <zijun_hu@...oud.com>
To: Fan Ni <nifan.cxl@...il.com>,
 Jonathan Cameron <jonathan.cameron@...wei.com>
Cc: Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
 "Rafael J. Wysocki" <rafael@...nel.org>, Tejun Heo <tj@...nel.org>,
 Josef Bacik <josef@...icpanda.com>, Jens Axboe <axboe@...nel.dk>,
 Boris Burkov <boris@....io>, Davidlohr Bueso <dave@...olabs.net>,
 Jonathan Cameron <jonathan.cameron@...wei.com>,
 Dave Jiang <dave.jiang@...el.com>,
 Alison Schofield <alison.schofield@...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,
 cgroups@...r.kernel.org, linux-block@...r.kernel.org,
 linux-cxl@...r.kernel.org, Zijun Hu <quic_zijuhu@...cinc.com>
Subject: Re: [PATCH v3 4/9] driver core: Move true expression out of if
 condition in API driver_find_device()

On 2024/12/17 02:01, Fan Ni wrote:
> On Thu, Dec 12, 2024 at 09:38:40PM +0800, Zijun Hu wrote:
>> From: Zijun Hu <quic_zijuhu@...cinc.com>
>>
>> For driver_find_device(), get_device() in the if condition always returns
>> true, move it to if body to make the API's logic more clearer.
>>
>> Signed-off-by: Zijun Hu <quic_zijuhu@...cinc.com>
>> ---
> 
> This patch and the next patch can be squished into one patch.
> 
> Reviewed-by: Fan Ni <fan.ni@...sung.com>
> 

thank you Fan and Jonathan for code review.

good suggestion.
will squish the three similar changes into one in v4. (^^)(^^)

>>  drivers/base/driver.c | 7 +++++--
>>  1 file changed, 5 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/base/driver.c b/drivers/base/driver.c
>> index b4eb5b89c4ee7bc35458fc75730b16a6d1e804d3..6f033a741aa7ce6138d1c61e49e72b2a3eb85e06 100644
>> --- a/drivers/base/driver.c
>> +++ b/drivers/base/driver.c
>> @@ -160,9 +160,12 @@ struct device *driver_find_device(const struct device_driver *drv,
>>  
>>  	klist_iter_init_node(&drv->p->klist_devices, &i,
>>  			     (start ? &start->p->knode_driver : NULL));
>> -	while ((dev = next_device(&i)))
>> -		if (match(dev, data) && get_device(dev))
>> +	while ((dev = next_device(&i))) {
>> +		if (match(dev, data)) {
>> +			get_device(dev);
>>  			break;
>> +		}
>> +	}
>>  	klist_iter_exit(&i);
>>  	return dev;
>>  }
>>
>> -- 
>> 2.34.1
>>
> 


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ