Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1390771

[PATCH] Use existing helper to convert "on/off" to boolean

From Minfei Huang <mnghuan@gmail.com>
Newsgroups linux.kernel
Subject [PATCH] Use existing helper to convert "on/off" to boolean
Date 2016-04-29 07:50 +0200
Message-ID <rt9to-KD-5@gated-at.bofh.it> (permalink)
Organization linux.* mail to news gateway

Show all headers | View raw


It's more convenient to use existing function helper to convert string
"on/off" to boolean.

Signed-off-by: Minfei Huang <mnghuan@gmail.com>
---
 lib/kstrtox.c    | 2 +-
 mm/page_alloc.c  | 9 +--------
 mm/page_poison.c | 8 +-------
 3 files changed, 3 insertions(+), 16 deletions(-)

diff --git a/lib/kstrtox.c b/lib/kstrtox.c
index d8a5cf6..3c66fc4 100644
--- a/lib/kstrtox.c
+++ b/lib/kstrtox.c
@@ -326,7 +326,7 @@ EXPORT_SYMBOL(kstrtos8);
  * @s: input string
  * @res: result
  *
- * This routine returns 0 iff the first character is one of 'Yy1Nn0', or
+ * This routine returns 0 if the first character is one of 'Yy1Nn0', or
  * [oO][NnFf] for "on" and "off". Otherwise it will return -EINVAL.  Value
  * pointed to by res is updated upon finding a match.
  */
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 59de90d..d31426d 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -513,14 +513,7 @@ static int __init early_debug_pagealloc(char *buf)
 {
 	if (!buf)
 		return -EINVAL;
-
-	if (strcmp(buf, "on") == 0)
-		_debug_pagealloc_enabled = true;
-
-	if (strcmp(buf, "off") == 0)
-		_debug_pagealloc_enabled = false;
-
-	return 0;
+	return kstrtobool(buf, &_debug_pagealloc_enabled);
 }
 early_param("debug_pagealloc", early_debug_pagealloc);
 
diff --git a/mm/page_poison.c b/mm/page_poison.c
index 479e7ea..1eae5fa 100644
--- a/mm/page_poison.c
+++ b/mm/page_poison.c
@@ -13,13 +13,7 @@ static int early_page_poison_param(char *buf)
 {
 	if (!buf)
 		return -EINVAL;
-
-	if (strcmp(buf, "on") == 0)
-		want_page_poisoning = true;
-	else if (strcmp(buf, "off") == 0)
-		want_page_poisoning = false;
-
-	return 0;
+	return strtobool(buf, &want_page_poisoning);
 }
 early_param("page_poison", early_page_poison_param);
 
-- 
2.6.3

Back to linux.kernel | Previous | NextNext in thread | Find similar | Unroll thread


Thread

[PATCH] Use existing helper to convert "on/off" to boolean Minfei Huang <mnghuan@gmail.com> - 2016-04-29 07:50 +0200
  Re: [PATCH] Use existing helper to convert "on/off" to boolean Michal Hocko <mhocko@kernel.org> - 2016-04-29 10:10 +0200
    Re: [PATCH] Use existing helper to convert "on/off" to boolean Minfei Huang <mnghuan@gmail.com> - 2016-04-29 11:10 +0200
      Re: [PATCH] Use existing helper to convert "on/off" to boolean Michal Hocko <mhocko@kernel.org> - 2016-04-29 11:30 +0200
  Re: [PATCH] Use existing helper to convert "on/off" to boolean Andrew Morton <akpm@linux-foundation.org> - 2016-04-29 23:30 +0200
    Re: [PATCH] Use existing helper to convert "on/off" to boolean Minfei Huang <mnghuan@gmail.com> - 2016-04-30 06:50 +0200

csiph-web