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, 10 Jun 2024 21:28:39 +0900 (JST)
From: FUJITA Tomonori <fujita.tomonori@...il.com>
To: linux@...linux.org.uk
Cc: fujita.tomonori@...il.com, netdev@...r.kernel.org, andrew@...n.ch,
 horms@...nel.org, kuba@...nel.org, jiri@...nulli.us, pabeni@...hat.com,
 hfdevel@....net, naveenm@...vell.com, jdamato@...tly.com
Subject: Re: [PATCH net-next v9 4/6] net: tn40xx: add basic Rx handling

On Mon, 10 Jun 2024 10:59:08 +0100
"Russell King (Oracle)" <linux@...linux.org.uk> wrote:

> On Thu, Jun 06, 2024 at 08:26:06AM +0900, FUJITA Tomonori wrote:
>> +static int tn40_rxdb_alloc_elem(struct tn40_rxdb *db)
>> +{
>> +	return db->stack[--(db->top)];
> 
> Parens are unnecessary here.

I'll fix.

>> +static void tn40_rxdb_free_elem(struct tn40_rxdb *db, unsigned int n)
>> +{
>> +	db->stack[(db->top)++] = n;
> 
> Same here.

I'll fix.

>> +	dno = tn40_rxdb_available(db) - 1;
>> +	i = dno;
>> +	while (i > 0) {
>> +		page = page_pool_dev_alloc_pages(priv->page_pool);
>> +		if (!page)
>> +			break;
>> +
>> +		idx = tn40_rxdb_alloc_elem(db);
>> +		tn40_set_rx_desc(priv, idx, page_pool_get_dma_addr(page));
>> +		dm = tn40_rxdb_addr_elem(db, idx);
>> +		dm->page = page;
>> +
>> +		i--;
>> +	}
> 
> While reviewing the rxdb stack, I came across this - this while() loop
> is an open-coded for() loop:
> 
> 	for (i = dno; i > 0; i--) {
> 		page = page_pool_dev_alloc_pages(priv->page_pool);
> 		...
> 		dm->page = page;
> 	}
> 
> Is there any reason not to use a for() loop here?

The while() loop here came from the original vendor code. Surely,
for() loop here is more readable. I'll change.

>>+struct tn40_rxdb {
>> +	int *stack;
>> +	struct tn40_rx_map *elems;
>> +	int nelem;
>> +	int top;
> 
> I assume neither of these should ever be negative, so should these be
> "unsigned int" ?

Yes, unsigned int is more appropriate for nelem and top. stack also
better to be unsigned int*, I think.


Thanks!

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ