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]
Date:   Wed, 28 Apr 2021 11:08:43 +0200
From:   Christophe JAILLET <christophe.jaillet@...adoo.fr>
To:     pbonzini@...hat.com, seanjc@...gle.com, vkuznets@...hat.com,
        wanpengli@...cent.com, jmattson@...gle.com, joro@...tes.org,
        tglx@...utronix.de, mingo@...hat.com, bp@...en8.de, x86@...nel.org,
        hpa@...or.com
Cc:     kvm@...r.kernel.org, linux-kernel@...r.kernel.org,
        kernel-janitors@...r.kernel.org,
        Christophe JAILLET <christophe.jaillet@...adoo.fr>
Subject: [PATCH] x86/kvm: Use 'hlist_for_each_entry' to simplify code

Use 'hlist_for_each_entry' instead of hand writing it.
This saves a few lines of code.

Signed-off-by: Christophe JAILLET <christophe.jaillet@...adoo.fr>
---
Compile tested only
---
 arch/x86/kernel/kvm.c | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c
index d307c22e5c18..35f5a0898b92 100644
--- a/arch/x86/kernel/kvm.c
+++ b/arch/x86/kernel/kvm.c
@@ -89,14 +89,11 @@ static struct kvm_task_sleep_head {
 static struct kvm_task_sleep_node *_find_apf_task(struct kvm_task_sleep_head *b,
 						  u32 token)
 {
-	struct hlist_node *p;
+	struct kvm_task_sleep_node *n;
 
-	hlist_for_each(p, &b->list) {
-		struct kvm_task_sleep_node *n =
-			hlist_entry(p, typeof(*n), link);
+	hlist_for_each_entry(n, &b->list, link)
 		if (n->token == token)
 			return n;
-	}
 
 	return NULL;
 }
@@ -169,14 +166,12 @@ static void apf_task_wake_all(void)
 	for (i = 0; i < KVM_TASK_SLEEP_HASHSIZE; i++) {
 		struct kvm_task_sleep_head *b = &async_pf_sleepers[i];
 		struct kvm_task_sleep_node *n;
-		struct hlist_node *p, *next;
+		struct hlist_node *next;
 
 		raw_spin_lock(&b->lock);
-		hlist_for_each_safe(p, next, &b->list) {
-			n = hlist_entry(p, typeof(*n), link);
+		hlist_for_each_entry_safe(n, next, &b->list, link)
 			if (n->cpu == smp_processor_id())
 				apf_task_wake_one(n);
-		}
 		raw_spin_unlock(&b->lock);
 	}
 }
-- 
2.30.2

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ