arch/x86/boot/string.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
The variable delta is being initialized with a value that is never
read. The assignment is redundant and can be removed.
Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
---
arch/x86/boot/string.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/x86/boot/string.c b/arch/x86/boot/string.c
index 1c8541ae3b3a..c23f3b9c84fe 100644
--- a/arch/x86/boot/string.c
+++ b/arch/x86/boot/string.c
@@ -49,7 +49,7 @@ int strcmp(const char *str1, const char *str2)
{
const unsigned char *s1 = (const unsigned char *)str1;
const unsigned char *s2 = (const unsigned char *)str2;
- int delta = 0;
+ int delta;
while (*s1 || *s2) {
delta = *s1 - *s2;
--
2.39.2
The following commit has been merged into the x86/boot branch of tip:
Commit-ID: 257ca14f4d780e27a0605fd68053d2cc3178a232
Gitweb: https://git.kernel.org/tip/257ca14f4d780e27a0605fd68053d2cc3178a232
Author: Colin Ian King <colin.i.king@gmail.com>
AuthorDate: Tue, 19 Dec 2023 14:13:04
Committer: Ingo Molnar <mingo@kernel.org>
CommitterDate: Wed, 20 Dec 2023 22:23:33 +01:00
x86/boot: Remove redundant initialization of the 'delta' variable in strcmp()
The 'delta' variable is zero-initialized, but never
read before the real initialization happens.
The assignment is redundant and can be removed.
Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Link: https://lore.kernel.org/r/20231219141304.367200-1-colin.i.king@gmail.com
---
arch/x86/boot/string.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/x86/boot/string.c b/arch/x86/boot/string.c
index 1c8541a..c23f3b9 100644
--- a/arch/x86/boot/string.c
+++ b/arch/x86/boot/string.c
@@ -49,7 +49,7 @@ int strcmp(const char *str1, const char *str2)
{
const unsigned char *s1 = (const unsigned char *)str1;
const unsigned char *s2 = (const unsigned char *)str2;
- int delta = 0;
+ int delta;
while (*s1 || *s2) {
delta = *s1 - *s2;
© 2016 - 2025 Red Hat, Inc.