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: <aQ2iJUZUDf5FLAW-@smile.fi.intel.com>
Date: Fri, 7 Nov 2025 09:39:17 +0200
From: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
To: Ira Weiny <ira.weiny@...el.com>
Cc: 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 Thu, Nov 06, 2025 at 06:46:48PM -0600, Ira Weiny wrote:
> Andy Shevchenko wrote:
> > In the snippets like the following
> > 
> > 	if (...)
> > 		return / goto / break / continue ...;
> > 	else
> > 		...
> > 
> > the 'else' is redundant. Get rid of it.
> 
> I still need a why to in this commit message.

Sure.

[snip]

...

> > -	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;
> 
> This is not an equivalent change.

It's (okau. almost. later on that). The parameter to the function is enum and
the listed values of the enum is all there. The problematic part can be if
somebody supplies an arbitrary value here. Yes, in such a case it will change
behaviour and I think it is correct in my case as UNKNOWN is unknown, and NONE
is actually well known 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;
> 
> This is not an equivalent change.

Same explanation as above. I'll put it into the commit message.

-- 
With Best Regards,
Andy Shevchenko



Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ