mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
	x86@kernel.org, "H. Peter Anvin" <hpa@zytor.com>,
	linux-kernel@vger.kernel.org
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Subject: [PATCH v1 2/2] x86/mtrr: Use strstrip() to cut extra spaces
Date: Mon,  9 Dec 2019 19:42:48 +0200	[thread overview]
Message-ID: <20191209174248.45342-2-andriy.shevchenko@linux.intel.com> (raw)
In-Reply-To: <20191209174248.45342-1-andriy.shevchenko@linux.intel.com>

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


      reply	other threads:[~2019-12-09 18:00 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-09 17:42 [PATCH v1 1/2] x86/mtrr: Make use of macros from mm.h Andy Shevchenko
2019-12-09 17:42 ` Andy Shevchenko [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191209174248.45342-2-andriy.shevchenko@linux.intel.com \
    --to=andriy.shevchenko@linux.intel.com \
    --cc=bp@alien8.de \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome