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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20240715102359.GA55002@unreal>
Date: Mon, 15 Jul 2024 13:23:59 +0300
From: Leon Romanovsky <leon@...nel.org>
To: David Laight <David.Laight@...lab.com>
Cc: Anand Khoje <anand.a.khoje@...cle.com>,
	"linux-rdma@...r.kernel.org" <linux-rdma@...r.kernel.org>,
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
	"netdev@...r.kernel.org" <netdev@...r.kernel.org>,
	"saeedm@...lanox.com" <saeedm@...lanox.com>,
	"tariqt@...dia.com" <tariqt@...dia.com>,
	"edumazet@...gle.com" <edumazet@...gle.com>,
	"kuba@...nel.org" <kuba@...nel.org>,
	"pabeni@...hat.com" <pabeni@...hat.com>,
	"davem@...emloft.net" <davem@...emloft.net>
Subject: Re: [PATCH v4] net/mlx5: Reclaim max 50K pages at once

On Mon, Jul 15, 2024 at 08:22:19AM +0000, David Laight wrote:
> From: Leon Romanovsky
> > Sent: 01 July 2024 12:50
> > To: David Laight <David.Laight@...LAB.COM>
> ...
> > > > BTW, this can be written as:
> > > > 	req->npages = max_t(s32, npages, MAX_RECLAIM_NPAGES);
> > >
> > > That shouldn't need all the (s32) casts.
> > 
> > #define doesn't have a type, so it is better to be explicit here.
> 
> The constant has a type, the cast just hides any checking that might be done.

According to the C standard, type can be int, long int or long long int:
 "The type of an integer constant is the first of the corresponding list
 in which its value can be represented.".

> Would you really write:
> 	if ((s32)npages > (s32)-50000)
> 		...
> Because that is what you are generating.
>

So instead of comparing s32 with int, which can be misleading. I prefer to compare s32 with s32.
 
> Here it probably doesn't matter, but it is really bad practise.
> If, for example, 'npages' is 64 bit than the cast can change the value.

In our case npages is s32.

Thanks

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ