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-next>] [day] [month] [year] [list]
Date:   Tue, 26 Oct 2021 11:13:10 -0400
From:   Qian Cai <quic_qiancai@...cinc.com>
To:     Paolo Bonzini <pbonzini@...hat.com>
CC:     <kvm@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
        Qian Cai <quic_qiancai@...cinc.com>
Subject: [PATCH] kvm: Avoid shadowing a local in search_memslots()

It is less error-prone to use a different variable name from the existing
one in a wider scope. This is also flagged by GCC (W=2):

./include/linux/kvm_host.h: In function 'search_memslots':
./include/linux/kvm_host.h:1246:7: warning: declaration of 'slot' shadows a previous local [-Wshadow]
 1246 |   int slot = start + (end - start) / 2;
      |       ^~~~
./include/linux/kvm_host.h:1240:26: note: shadowed declaration is here
 1240 |  struct kvm_memory_slot *slot;
      |                          ^~~~

Signed-off-by: Qian Cai <quic_qiancai@...cinc.com>
---
 include/linux/kvm_host.h | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
index 60a35d9fe259..1c1a36f658fe 100644
--- a/include/linux/kvm_host.h
+++ b/include/linux/kvm_host.h
@@ -1243,12 +1243,12 @@ search_memslots(struct kvm_memslots *slots, gfn_t gfn, int *index)
 		return NULL;
 
 	while (start < end) {
-		int slot = start + (end - start) / 2;
+		int new_slot = start + (end - start) / 2;
 
-		if (gfn >= memslots[slot].base_gfn)
-			end = slot;
+		if (gfn >= memslots[new_slot].base_gfn)
+			end = new_slot;
 		else
-			start = slot + 1;
+			start = new_slot + 1;
 	}
 
 	slot = try_get_memslot(slots, start, gfn);
-- 
2.30.2

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ