Skip to content

Commit

Permalink
x86/mtrr: Remove unnecessary strlen() in mtrr_write()
Browse files Browse the repository at this point in the history
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@linux.dev>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Link: https://lore.kernel.org/r/20250225131621.329699-2-thorsten.blum@linux.dev
  • Loading branch information
Thorsten Blum authored and Ingo Molnar committed Feb 25, 2025
1 parent 782b819 commit 8e8f030
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions arch/x86/kernel/cpu/mtrr/if.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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)) {
Expand Down

0 comments on commit 8e8f030

Please sign in to comment.