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] [thread-next>] [day] [month] [year] [list]
Message-ID: <tip-0286d538082b854b4e1f05b29c23556fa344e145@git.kernel.org>
Date:	Fri, 10 Jun 2016 02:48:51 -0700
From:	tip-bot for Rui Wang <tipbot@...or.com>
To:	linux-tip-commits@...r.kernel.org
Cc:	hpa@...or.com, rui.y.wang@...el.com, tglx@...utronix.de,
	linux-kernel@...r.kernel.org, mingo@...nel.org
Subject: [tip:x86/apic] x86/ioapic: Simplify ioapic_setup_resources()

Commit-ID:  0286d538082b854b4e1f05b29c23556fa344e145
Gitweb:     http://git.kernel.org/tip/0286d538082b854b4e1f05b29c23556fa344e145
Author:     Rui Wang <rui.y.wang@...el.com>
AuthorDate: Wed, 8 Jun 2016 14:59:53 +0800
Committer:  Thomas Gleixner <tglx@...utronix.de>
CommitDate: Fri, 10 Jun 2016 11:43:52 +0200

x86/ioapic: Simplify ioapic_setup_resources()

Optimize the function by removing the variable 'num'.

Signed-off-by: Rui Wang <rui.y.wang@...el.com>
Cc: tony.luck@...el.com
Cc: linux-pci@...r.kernel.org
Cc: rjw@...ysocki.net
Cc: linux-acpi@...r.kernel.org
Cc: bhelgaas@...gle.com
Link: http://lkml.kernel.org/r/1465369193-4816-4-git-send-email-rui.y.wang@intel.com
Signed-off-by: Thomas Gleixner <tglx@...utronix.de>

---
 arch/x86/kernel/apic/io_apic.c | 18 +++++++-----------
 1 file changed, 7 insertions(+), 11 deletions(-)

diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c
index 446702e..e587295 100644
--- a/arch/x86/kernel/apic/io_apic.c
+++ b/arch/x86/kernel/apic/io_apic.c
@@ -2567,29 +2567,25 @@ static struct resource * __init ioapic_setup_resources(void)
 	unsigned long n;
 	struct resource *res;
 	char *mem;
-	int i, num = 0;
+	int i;
 
-	for_each_ioapic(i)
-		num++;
-	if (num == 0)
+	if (nr_ioapics == 0)
 		return NULL;
 
 	n = IOAPIC_RESOURCE_NAME_SIZE + sizeof(struct resource);
-	n *= num;
+	n *= nr_ioapics;
 
 	mem = alloc_bootmem(n);
 	res = (void *)mem;
 
-	mem += sizeof(struct resource) * num;
+	mem += sizeof(struct resource) * nr_ioapics;
 
-	num = 0;
 	for_each_ioapic(i) {
-		res[num].name = mem;
-		res[num].flags = IORESOURCE_MEM | IORESOURCE_BUSY;
+		res[i].name = mem;
+		res[i].flags = IORESOURCE_MEM | IORESOURCE_BUSY;
 		snprintf(mem, IOAPIC_RESOURCE_NAME_SIZE, "IOAPIC %u", i);
 		mem += IOAPIC_RESOURCE_NAME_SIZE;
-		ioapics[i].iomem_res = &res[num];
-		num++;
+		ioapics[i].iomem_res = &res[i];
 	}
 
 	ioapic_resources = res;

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ