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: <aQ0LtdyI4XzL1yDs@aschofie-mobl2.lan>
Date: Thu, 6 Nov 2025 12:57:25 -0800
From: Alison Schofield <alison.schofield@...el.com>
To: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
CC: Ira Weiny <ira.weiny@...el.com>, <nvdimm@...ts.linux.dev>,
	<linux-kernel@...r.kernel.org>, Dan Williams <dan.j.williams@...el.com>,
	Vishal Verma <vishal.l.verma@...el.com>, Dave Jiang <dave.jiang@...el.com>
Subject: Re: [PATCH v1 1/1] libnvdimm/labels: Get rid of redundant 'else'

On Wed, Nov 05, 2025 at 07:37:43PM +0100, Andy Shevchenko wrote:
> In the snippets like the following
> 
> 	if (...)
> 		return / goto / break / continue ...;
> 	else
> 		...
> 
> the 'else' is redundant. Get rid of it.

The commit msg doesn't explain why the functional change in this
checkpatch cleanup is OK?

It looks like both to_abstraction_guid() and to_abstraction_uuid()
change the behavior for invalid or unexpected enum values. They use
to return &guid_null or &uuid_null, and with this patch they now
return target. That seems to remove our protection against future
enum values or corrupted enum val.


> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
> ---
>  drivers/nvdimm/label.c | 60 ++++++++++++++++++++----------------------
>  1 file changed, 29 insertions(+), 31 deletions(-)
> 
> diff --git a/drivers/nvdimm/label.c b/drivers/nvdimm/label.c
> index 04f4a049599a..b129f3a55a70 100644
> --- a/drivers/nvdimm/label.c
> +++ b/drivers/nvdimm/label.c

snip to the abstraction funcs

> @@ -768,20 +768,20 @@ static const guid_t *to_abstraction_guid(enum nvdimm_claim_class claim_class,
>  {
>  	if (claim_class == NVDIMM_CCLASS_BTT)
>  		return &nvdimm_btt_guid;
> -	else if (claim_class == NVDIMM_CCLASS_BTT2)
> +	if (claim_class == NVDIMM_CCLASS_BTT2)
>  		return &nvdimm_btt2_guid;
> -	else if (claim_class == NVDIMM_CCLASS_PFN)
> +	if (claim_class == NVDIMM_CCLASS_PFN)
>  		return &nvdimm_pfn_guid;
> -	else if (claim_class == NVDIMM_CCLASS_DAX)
> +	if (claim_class == NVDIMM_CCLASS_DAX)
>  		return &nvdimm_dax_guid;
> -	else if (claim_class == NVDIMM_CCLASS_UNKNOWN) {
> -		/*
> -		 * If we're modifying a namespace for which we don't
> -		 * know the claim_class, don't touch the existing guid.
> -		 */
> -		return target;
> -	} else
> +	if (claim_class == NVDIMM_CCLASS_NONE)
>  		return &guid_null;
> +
> +	/*
> +	 * If we're modifying a namespace for which we don't
> +	 * know the claim_class, don't touch the existing guid.
> +	 */
> +	return target;
>  }
>  
>  /* CXL labels store UUIDs instead of GUIDs for the same data */
> @@ -790,20 +790,20 @@ static const uuid_t *to_abstraction_uuid(enum nvdimm_claim_class claim_class,
>  {
>  	if (claim_class == NVDIMM_CCLASS_BTT)
>  		return &nvdimm_btt_uuid;
> -	else if (claim_class == NVDIMM_CCLASS_BTT2)
> +	if (claim_class == NVDIMM_CCLASS_BTT2)
>  		return &nvdimm_btt2_uuid;
> -	else if (claim_class == NVDIMM_CCLASS_PFN)
> +	if (claim_class == NVDIMM_CCLASS_PFN)
>  		return &nvdimm_pfn_uuid;
> -	else if (claim_class == NVDIMM_CCLASS_DAX)
> +	if (claim_class == NVDIMM_CCLASS_DAX)
>  		return &nvdimm_dax_uuid;
> -	else if (claim_class == NVDIMM_CCLASS_UNKNOWN) {
> -		/*
> -		 * If we're modifying a namespace for which we don't
> -		 * know the claim_class, don't touch the existing uuid.
> -		 */
> -		return target;
> -	} else
> +	if (claim_class == NVDIMM_CCLASS_NONE)
>  		return &uuid_null;
> +
> +	/*
> +	 * If we're modifying a namespace for which we don't
> +	 * know the claim_class, don't touch the existing uuid.
> +	 */
> +	return target;
>  }
>  
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ