Skip to content

Commit c9ad8e0

Browse files
committed
ACPI: acpi_pad: simplify code to avoid false gcc build warning
acpi_pad.c:432: warning: ‘num_cpus’ may be used uninitialized in this function gcc 4.4.4 was unable to notice that num_cpus is always set. Re-arrange the code to un-confuse gcc, and also make it easier for humans to read.... Signed-off-by: Len Brown <[email protected]>
1 parent 25cb1bf commit c9ad8e0

File tree

1 file changed

+18
-16
lines changed

1 file changed

+18
-16
lines changed

drivers/acpi/acpi_pad.c

+18-16
Original file line numberDiff line numberDiff line change
@@ -382,31 +382,32 @@ static void acpi_pad_remove_sysfs(struct acpi_device *device)
382382
device_remove_file(&device->dev, &dev_attr_rrtime);
383383
}
384384

385-
/* Query firmware how many CPUs should be idle */
386-
static int acpi_pad_pur(acpi_handle handle, int *num_cpus)
385+
/*
386+
* Query firmware how many CPUs should be idle
387+
* return -1 on failure
388+
*/
389+
static int acpi_pad_pur(acpi_handle handle)
387390
{
388391
struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL};
389392
union acpi_object *package;
390-
int rev, num, ret = -EINVAL;
393+
int num = -1;
391394

392395
if (ACPI_FAILURE(acpi_evaluate_object(handle, "_PUR", NULL, &buffer)))
393-
return -EINVAL;
396+
return num;
394397

395398
if (!buffer.length || !buffer.pointer)
396-
return -EINVAL;
399+
return num;
397400

398401
package = buffer.pointer;
399-
if (package->type != ACPI_TYPE_PACKAGE || package->package.count != 2)
400-
goto out;
401-
rev = package->package.elements[0].integer.value;
402-
num = package->package.elements[1].integer.value;
403-
if (rev != 1 || num < 0)
404-
goto out;
405-
*num_cpus = num;
406-
ret = 0;
407-
out:
402+
403+
if (package->type == ACPI_TYPE_PACKAGE &&
404+
package->package.count == 2 &&
405+
package->package.elements[0].integer.value == 1) /* rev 1 */
406+
407+
num = package->package.elements[1].integer.value;
408+
408409
kfree(buffer.pointer);
409-
return ret;
410+
return num;
410411
}
411412

412413
/* Notify firmware how many CPUs are idle */
@@ -433,7 +434,8 @@ static void acpi_pad_handle_notify(acpi_handle handle)
433434
uint32_t idle_cpus;
434435

435436
mutex_lock(&isolated_cpus_lock);
436-
if (acpi_pad_pur(handle, &num_cpus)) {
437+
num_cpus = acpi_pad_pur(handle);
438+
if (num_cpus < 0) {
437439
mutex_unlock(&isolated_cpus_lock);
438440
return;
439441
}

0 commit comments

Comments
 (0)