Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1707424
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH v2 8/9] ACPI-video: Move four assignments in acpi_video_get_levels() |
| Date | 2017-08-09 17:50 +0200 |
| Message-ID | <ucBp7-PO-5@gated-at.bofh.it> (permalink) |
| References | (3 earlier) <seffb-4Kg-7@gated-at.bofh.it> <semJH-1kY-9@gated-at.bofh.it> <sepod-36Y-1@gated-at.bofh.it> <sevN0-7ef-19@gated-at.bofh.it> <ucBfr-Mz-7@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 9 Aug 2017 16:21:17 +0200
Move the assignments for four local variables so that they will only
be performed if the corresponding data processing succeeded
by this function.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/acpi/acpi_video.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/drivers/acpi/acpi_video.c b/drivers/acpi/acpi_video.c
index a899faf6ff84..3cc1798676ab 100644
--- a/drivers/acpi/acpi_video.c
+++ b/drivers/acpi/acpi_video.c
@@ -801,10 +801,10 @@ int acpi_video_get_levels(struct acpi_device *device,
int *pmax_level)
{
union acpi_object *obj = NULL;
- int i, max_level = 0, count = 0, level_ac_battery = 0;
+ int i, max_level, count, level_ac_battery;
union acpi_object *o;
struct acpi_video_device_brightness *br;
- int result = 0;
+ int result;
u32 value;
if (!ACPI_SUCCESS(acpi_video_device_lcd_query_levels(device->handle,
@@ -838,6 +838,8 @@ int acpi_video_get_levels(struct acpi_device *device,
goto out_free;
}
+ max_level = 0;
+ count = 0;
for (i = 0; i < obj->package.count; i++) {
o = (union acpi_object *)&obj->package.elements[i];
if (o->type != ACPI_TYPE_INTEGER) {
@@ -863,6 +865,7 @@ int acpi_video_get_levels(struct acpi_device *device,
* In this case, the first two elements in _BCL packages
* are also supported brightness levels that OS should take care of.
*/
+ level_ac_battery = 0;
for (i = ACPI_VIDEO_FIRST_LEVEL; i < count; i++) {
if (br->levels[i] == br->levels[ACPI_VIDEO_AC_LEVEL])
level_ac_battery++;
@@ -895,7 +898,7 @@ int acpi_video_get_levels(struct acpi_device *device,
*dev_br = br;
if (pmax_level)
*pmax_level = max_level;
-
+ result = 0;
out:
kfree(obj);
return result;
--
2.13.4
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH v2 0/9] ACPI-video: Fine-tuning for several function implementations SF Markus Elfring <elfring@users.sourceforge.net> - 2017-08-09 17:40 +0200 [PATCH v2 1/9] ACPI-video: Use kmalloc_array() in acpi_video_get_levels() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-08-09 17:40 +0200 [PATCH v2 3/9] ACPI-video: Delete an error message for a failed kzalloc() call SF Markus Elfring <elfring@users.sourceforge.net> - 2017-08-09 17:40 +0200 [PATCH v2 2/9] ACPI-video: Return directly after a failed device query SF Markus Elfring <elfring@users.sourceforge.net> - 2017-08-09 17:40 +0200 [PATCH v2 9/9] ACPI-video: Improve a size determination in four functions SF Markus Elfring <elfring@users.sourceforge.net> - 2017-08-09 17:50 +0200 [PATCH v2 8/9] ACPI-video: Move four assignments in acpi_video_get_levels() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-08-09 17:50 +0200 [PATCH v2 4/9] ACPI-video: Return directly after a failed input_allocate_device() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-08-09 17:50 +0200 [PATCH v2 6/9] ACPI-video: Improve a jump target in acpi_video_switch_brightness() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-08-09 17:50 +0200 [PATCH v2 7/9] ACPI-video: Delete an unnecessary initialisation in three functions SF Markus Elfring <elfring@users.sourceforge.net> - 2017-08-09 17:50 +0200 [PATCH v2 5/9] ACPI-video: Delete unnecessary if statement in acpi_video_switch_brightness() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-08-09 17:50 +0200
csiph-web