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: <20251210212656.GA3539214@bhelgaas>
Date: Wed, 10 Dec 2025 15:26:56 -0600
From: Bjorn Helgaas <helgaas@...nel.org>
To: Christian Marangi <ansuelsmth@...il.com>
Cc: Andrew Morton <akpm@...ux-foundation.org>,
	Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
	linux-kernel@...r.kernel.org,
	Ilpo Järvinen <ilpo.jarvinen@...ux.intel.com>
Subject: Re: [PATCH] resource: provide 0args DEFINE_RES variant for unset
 resource desc

On Wed, Dec 10, 2025 at 07:03:07PM +0100, Christian Marangi wrote:
> Provide a variant of DEFINE_RES that takes 0 arguments to inizialize an
> "unset" resource descriptor.

s/inizialize/initialize/

> This should be used for the improper case of
> 
> 	struct resource res = {};
> 
> where DEFINE_RES() should be used.
> 
> With this new helper variant, it would result in:
> 
> 	struct resource res = DEFINE_RES();
> 
> instead of having to define the full 3 arguments:
> 
> 	struct resource res = DEFINE_RES(0, 0, IORESOURCE_UNSET);
> 
> DEFINE_RES() with no args, will set the flags to IORESOURCE_UNSET
> signaling the resource descriptor is UNSET and doesn't reflect an actual
> resource currently.
> 
> Suggested-by: Ilpo Järvinen <ilpo.jarvinen@...ux.intel.com>
> Signed-off-by: Christian Marangi <ansuelsmth@...il.com>

Looks good to me, thanks for doing this!

Reviewed-by: Bjorn Helgaas <bhelgaas@...gle.com>

> ---
>  include/linux/ioport.h | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/include/linux/ioport.h b/include/linux/ioport.h
> index d3e837eb8760..ebdbaaf7a520 100644
> --- a/include/linux/ioport.h
> +++ b/include/linux/ioport.h
> @@ -168,8 +168,13 @@ enum {
>  
>  #define DEFINE_RES_NAMED(_start, _size, _name, _flags)			\
>  	DEFINE_RES_NAMED_DESC(_start, _size, _name, _flags, IORES_DESC_NONE)
> -#define DEFINE_RES(_start, _size, _flags)				\
> +#define __DEFINE_RES0()							\
> +	DEFINE_RES_NAMED(0, 0, NULL, IORESOURCE_UNSET)
> +#define __DEFINE_RES3(_start, _size, _flags)				\
>  	DEFINE_RES_NAMED(_start, _size, NULL, _flags)
> +#define DEFINE_RES(...)							\
> +	CONCATENATE(__DEFINE_RES, COUNT_ARGS(__VA_ARGS__))		\
> +		    (__VA_ARGS__)
>  
>  #define DEFINE_RES_IO_NAMED(_start, _size, _name)			\
>  	DEFINE_RES_NAMED((_start), (_size), (_name), IORESOURCE_IO)
> -- 
> 2.51.0
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ