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>] [day] [month] [year] [list]
Message-ID: <84e53330631549a68aa27ac61ea1da18@RCDC-Mail15.corp.diehl.com>
Date:   Fri, 10 Jun 2022 07:08:48 +0200 (CEST)
From:   Denis OSTERLAND-HEIM <denis.osterland@...hl.com>
To:     Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
        "linux-leds@...r.kernel.org" <linux-leds@...r.kernel.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Cc:     Pavel Machek <pavel@....cz>
Subject: RE: [PATCH v1 1/1] leds: core: Refactor led_update_brightness() to
 use standard pattern

LGTM

Acked-by: Denis Osterland-Heim <denis.osterland@...hl.com>

-----Original Message-----
From: Andy Shevchenko <andriy.shevchenko@...ux.intel.com> 
Sent: Thursday, June 9, 2022 6:23 PM
To: Denis OSTERLAND-HEIM <denis.osterland@...hl.com>; Andy Shevchenko
<andriy.shevchenko@...ux.intel.com>; linux-leds@...r.kernel.org;
linux-kernel@...r.kernel.org
Cc: Pavel Machek <pavel@....cz>
Subject: [PATCH v1 1/1] leds: core: Refactor led_update_brightness() to use
standard pattern

The standard conditional pattern is to check for errors first and
bail out if any. Refactor led_update_brightness() accordingly.

While at it, drop unneeded assignment and return 0 unconditionally
on success.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
---
 drivers/leds/led-core.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/leds/led-core.c b/drivers/leds/led-core.c
index 4a97cb745788..96a2817712e5 100644
--- a/drivers/leds/led-core.c
+++ b/drivers/leds/led-core.c
@@ -304,17 +304,17 @@ EXPORT_SYMBOL_GPL(led_set_brightness_sync);
 
 int led_update_brightness(struct led_classdev *led_cdev)
 {
-	int ret = 0;
+	int ret;
 
 	if (led_cdev->brightness_get) {
 		ret = led_cdev->brightness_get(led_cdev);
-		if (ret >= 0) {
-			led_cdev->brightness = ret;
-			return 0;
-		}
+		if (ret < 0)
+			return ret;
+
+		led_cdev->brightness = ret;
 	}
 
-	return ret;
+	return 0;
 }
 EXPORT_SYMBOL_GPL(led_update_brightness);
 
-- 
2.35.1

Download attachment "smime.p7s" of type "application/x-pkcs7-signature" (3908 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ