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]
Date:   Mon, 21 Nov 2022 09:51:46 -0800
From:   Jacob Keller <jacob.e.keller@...el.com>
To:     Jakub Kicinski <kuba@...nel.org>
CC:     <netdev@...r.kernel.org>, Jiri Pirko <jiri@...dia.com>
Subject: Re: [PATCH net-next 2/8] devlink: use min_t to calculate data_size



On 11/18/2022 5:36 PM, Jakub Kicinski wrote:
> On Thu, 17 Nov 2022 14:07:57 -0800 Jacob Keller wrote:
>> The calculation for the data_size in the devlink_nl_read_snapshot_fill
>> function uses an if statement that is better expressed using the min_t
>> macro.
>>
>> Noticed-by: Jakub Kicinski <kuba@...nel.org>
> 
> I'm afraid that's not a real tag. You can just drop it,
> I get sufficient credits.
> 

Sure. I pulled this forward from some time ago, not sure why I had added 
it back then. A grep through the log shows its been used a handful of 
times, but it likely just slipped in without review in the past. Will 
remove.

>> diff --git a/net/core/devlink.c b/net/core/devlink.c
>> index 96afc7013959..932476956d7e 100644
>> --- a/net/core/devlink.c
>> +++ b/net/core/devlink.c
>> @@ -6410,14 +6410,10 @@ static int devlink_nl_region_read_snapshot_fill(struct sk_buff *skb,
>>   	*new_offset = start_offset;
>>   
>>   	while (curr_offset < end_offset) {
>> -		u32 data_size;
>> +		u32 data_size = min_t(u32, end_offset - curr_offset,
>> +				      DEVLINK_REGION_READ_CHUNK_SIZE);
> 
> nit: don't put multi-line statements on the declaration line if it's
> not the only variable.
> 

Sure, that makes sense.

>>   		u8 *data;
>>   
>> -		if (end_offset - curr_offset < DEVLINK_REGION_READ_CHUNK_SIZE)
>> -			data_size = end_offset - curr_offset;
>> -		else
>> -			data_size = DEVLINK_REGION_READ_CHUNK_SIZE;

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ