lkml.org 
[lkml]   [2019]   [Dec]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH v1 2/2] x86/mtrr: Use strstrip() to cut extra spaces
Date
Cut all white spaces surrounding the passed line.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
arch/x86/kernel/cpu/mtrr/if.c | 16 ++++++----------
1 file changed, 6 insertions(+), 10 deletions(-)

diff --git a/arch/x86/kernel/cpu/mtrr/if.c b/arch/x86/kernel/cpu/mtrr/if.c
index a51eb8e4c079..9d251efdf064 100644
--- a/arch/x86/kernel/cpu/mtrr/if.c
+++ b/arch/x86/kernel/cpu/mtrr/if.c
@@ -97,10 +97,9 @@ mtrr_write(struct file *file, const char __user *buf, size_t len, loff_t * ppos)
int i, err;
unsigned long reg;
unsigned long long base, size;
- char *ptr;
+ char *ptr, *l;
char line[LINE_SIZE];
int length;
- size_t linelen;

if (!capable(CAP_SYS_ADMIN))
return -EPERM;
@@ -112,23 +111,20 @@ 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 = '\0';
+ l = strstrip(line);

- if (!strncmp(line, "disable=", 8)) {
- reg = simple_strtoul(line + 8, &ptr, 0);
+ if (!strncmp(l, "disable=", 8)) {
+ reg = simple_strtoul(l + 8, &ptr, 0);
err = mtrr_del_page(reg, 0, 0);
if (err < 0)
return err;
return len;
}

- if (strncmp(line, "base=", 5))
+ if (strncmp(l, "base=", 5))
return -EINVAL;

- base = simple_strtoull(line + 5, &ptr, 0);
+ base = simple_strtoull(l + 5, &ptr, 0);
ptr = skip_spaces(ptr);

if (strncmp(ptr, "size=", 5))
--
2.24.0
\
 
 \ /
  Last update: 2019-12-09 19:01    [W:0.033 / U:0.844 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site