Commit 362b7077 authored by Matthew Wilcox's avatar Matthew Wilcox Committed by Jesse Barnes
Browse files

PCI: fix bogus "'device' may be used uninitialized" warning in pci_slot



I get warnings about 'device' possibly being used uninitialised.  While
I can deduce this is not true, it seems that GCC can't.  This patch
changes `check_slot' to return device on success and -1 on error, which
shuts GCC up.

Acked-by: default avatarAlex Chiang <achiang@hp.com>
Signed-off-by: default avatarMatthew Wilcox <willy@linux.intel.com>
Signed-off-by: default avatarJesse Barnes <jbarnes@virtuousgeek.org>
parent d6d38574
Loading
Loading
Loading
Loading
+7 −11
Original line number Original line Diff line number Diff line
@@ -76,9 +76,9 @@ static struct acpi_pci_driver acpi_pci_slot_driver = {
};
};


static int
static int
check_slot(acpi_handle handle, int *device, unsigned long *sun)
check_slot(acpi_handle handle, unsigned long *sun)
{
{
	int retval = 0;
	int device = -1;
	unsigned long adr, sta;
	unsigned long adr, sta;
	acpi_status status;
	acpi_status status;
	struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
	struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
@@ -89,32 +89,27 @@ check_slot(acpi_handle handle, int *device, unsigned long *sun)
	if (check_sta_before_sun) {
	if (check_sta_before_sun) {
		/* If SxFy doesn't have _STA, we just assume it's there */
		/* If SxFy doesn't have _STA, we just assume it's there */
		status = acpi_evaluate_integer(handle, "_STA", NULL, &sta);
		status = acpi_evaluate_integer(handle, "_STA", NULL, &sta);
		if (ACPI_SUCCESS(status) && !(sta & ACPI_STA_DEVICE_PRESENT)) {
		if (ACPI_SUCCESS(status) && !(sta & ACPI_STA_DEVICE_PRESENT))
			retval = -1;
			goto out;
			goto out;
	}
	}
	}


	status = acpi_evaluate_integer(handle, "_ADR", NULL, &adr);
	status = acpi_evaluate_integer(handle, "_ADR", NULL, &adr);
	if (ACPI_FAILURE(status)) {
	if (ACPI_FAILURE(status)) {
		dbg("_ADR returned %d on %s\n", status, (char *)buffer.pointer);
		dbg("_ADR returned %d on %s\n", status, (char *)buffer.pointer);
		retval = -1;
		goto out;
		goto out;
	}
	}


	*device = (adr >> 16) & 0xffff;

	/* No _SUN == not a slot == bail */
	/* No _SUN == not a slot == bail */
	status = acpi_evaluate_integer(handle, "_SUN", NULL, sun);
	status = acpi_evaluate_integer(handle, "_SUN", NULL, sun);
	if (ACPI_FAILURE(status)) {
	if (ACPI_FAILURE(status)) {
		dbg("_SUN returned %d on %s\n", status, (char *)buffer.pointer);
		dbg("_SUN returned %d on %s\n", status, (char *)buffer.pointer);
		retval = -1;
		goto out;
		goto out;
	}
	}


	device = (adr >> 16) & 0xffff;
out:
out:
	kfree(buffer.pointer);
	kfree(buffer.pointer);
	return retval;
	return device;
}
}


struct callback_args {
struct callback_args {
@@ -144,7 +139,8 @@ register_slot(acpi_handle handle, u32 lvl, void *context, void **rv)
	struct callback_args *parent_context = context;
	struct callback_args *parent_context = context;
	struct pci_bus *pci_bus = parent_context->pci_bus;
	struct pci_bus *pci_bus = parent_context->pci_bus;


	if (check_slot(handle, &device, &sun))
	device = check_slot(handle, &sun);
	if (device < 0)
		return AE_OK;
		return AE_OK;


	slot = kmalloc(sizeof(*slot), GFP_KERNEL);
	slot = kmalloc(sizeof(*slot), GFP_KERNEL);