[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <174051362601.10177.9946583706077951040.tip-bot2@tip-bot2>
Date: Tue, 25 Feb 2025 20:00:26 -0000
From: "tip-bot2 for Thorsten Blum" <tip-bot2@...utronix.de>
To: linux-tip-commits@...r.kernel.org
Cc: Thorsten Blum <thorsten.blum@...ux.dev>, Ingo Molnar <mingo@...nel.org>,
x86@...nel.org, linux-kernel@...r.kernel.org
Subject: [tip: x86/mm] x86/mtrr: Remove unnecessary strlen() in mtrr_write()
The following commit has been merged into the x86/mm branch of tip:
Commit-ID: 8e8f0306497dea58fb4e8e2558949daae5eeac5c
Gitweb: https://git.kernel.org/tip/8e8f0306497dea58fb4e8e2558949daae5eeac5c
Author: Thorsten Blum <thorsten.blum@...ux.dev>
AuthorDate: Tue, 25 Feb 2025 14:16:19 +01:00
Committer: Ingo Molnar <mingo@...nel.org>
CommitterDate: Tue, 25 Feb 2025 20:50:55 +01:00
x86/mtrr: Remove unnecessary strlen() in mtrr_write()
The local variable length already holds the string length after calling
strncpy_from_user(). Using another local variable linlen and calling
strlen() is therefore unnecessary and can be removed. Remove linlen
and strlen() and use length instead.
No change in functionality intended.
Signed-off-by: Thorsten Blum <thorsten.blum@...ux.dev>
Signed-off-by: Ingo Molnar <mingo@...nel.org>
Link: https://lore.kernel.org/r/20250225131621.329699-2-thorsten.blum@linux.dev
---
arch/x86/kernel/cpu/mtrr/if.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/arch/x86/kernel/cpu/mtrr/if.c b/arch/x86/kernel/cpu/mtrr/if.c
index a5c506f..4049235 100644
--- a/arch/x86/kernel/cpu/mtrr/if.c
+++ b/arch/x86/kernel/cpu/mtrr/if.c
@@ -99,7 +99,6 @@ mtrr_write(struct file *file, const char __user *buf, size_t len, loff_t * ppos)
char *ptr;
char line[LINE_SIZE];
int length;
- size_t linelen;
memset(line, 0, LINE_SIZE);
@@ -108,9 +107,8 @@ mtrr_write(struct file *file, const char __user *buf, size_t len, loff_t * ppos)
if (length < 0)
return length;
- linelen = strlen(line);
- ptr = line + linelen - 1;
- if (linelen && *ptr == '\n')
+ ptr = line + length - 1;
+ if (length && *ptr == '\n')
*ptr = '\0';
if (!strncmp(line, "disable=", 8)) {
Powered by blists - more mailing lists