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] [day] [month] [year] [list]
Message-ID: <1492532921.8661.42.camel@perches.com>
Date:   Tue, 18 Apr 2017 09:28:41 -0700
From:   Joe Perches <joe@...ches.com>
To:     Mark Brown <broonie@...nel.org>, hubiaoyong <hubiaoyong@...il.com>
Cc:     lgirdwood@...il.com, linux-kernel@...r.kernel.org, hby2003@....com
Subject: Re: [PATCH] regulator/core.c: remove the else statement

On Tue, 2017-04-18 at 16:49 +0100, Mark Brown wrote:
> On Tue, Apr 18, 2017 at 11:39:34PM +0800, hubiaoyong wrote:
> > in the function regulator_ena_gpio_free, the if branch contains
> > the return statement, so remove the else statement.
> 
> Why is it a benefit to make this change?

In general, reducing source code indentation is a good thing.

The logic today is:

	/* Free the GPIO only in case of no use */
	list_for_each_entry_safe(pin, n, &regulator_ena_gpio_list, list) {
		if (pin->gpiod == rdev->ena_pin->gpiod) {
			if (pin->request_count <= 1) {
				pin->request_count = 0;
				gpiod_put(pin->gpiod);
				list_del(&pin->list);
				kfree(pin);
				rdev->ena_pin = NULL;
				return;
			} else {
				pin->request_count--;
			}
		}
	}

Perhaps it's better written as:

	/* Free the GPIO only in case of no use */
	list_for_each_entry_safe(pin, n, &regulator_ena_gpio_list, list) {
		if (pin->gpiod != rdev->ena_pin->gpiod)
			continue;
		if (pin->request_count <= 1) {
			pin->request_count = 0;
			gpiod_put(pin->gpiod);
			list_del(&pin->list);
			kfree(pin);
			rdev->ena_pin = NULL;
			return;
		}
		pin->request_count--;
	}

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ