All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Ben Hutchings <ben@decadent.org.uk>
Cc: Andrea Arcangeli <aarcange@redhat.com>,
	linux-mm@kvack.org, Mel Gorman <mel@csn.ul.ie>,
	Johannes Weiner <jweiner@redhat.com>,
	Rik van Riel <riel@redhat.com>, Hugh Dickins <hughd@google.com>
Subject: Re: [PATCH] mm/thp: Use conventional format for boolean attributes
Date: Wed, 13 Apr 2011 12:31:22 -0700	[thread overview]
Message-ID: <20110413123122.1adceba6.akpm@linux-foundation.org> (raw)
In-Reply-To: <1300772711.26693.473.camel@localhost>

On Tue, 22 Mar 2011 05:45:11 +0000
Ben Hutchings <ben@decadent.org.uk> wrote:

>  static ssize_t single_flag_store(struct kobject *kobj,
>  				 struct kobj_attribute *attr,
>  				 const char *buf, size_t count,
>  				 enum transparent_hugepage_flag flag)
>  {
> -	if (!memcmp("yes", buf,
> -		    min(sizeof("yes")-1, count))) {
> +	unsigned long value;
> +	char *endp;
> +
> +	value = simple_strtoul(buf, &endp, 0);

What the heck is this doing using simple_strtoul()?  checkpatch has
been telling us to use strict_strtoul() for ages, and lately it tells us
to use kstrtoul().

Please review and test asap:

--- a/mm/huge_memory.c~mm-thp-use-conventional-format-for-boolean-attributes-fix
+++ a/mm/huge_memory.c
@@ -247,16 +247,19 @@ static ssize_t single_flag_show(struct k
 	return sprintf(buf, "%d\n",
 		       test_bit(flag, &transparent_hugepage_flags));
 }
+
 static ssize_t single_flag_store(struct kobject *kobj,
 				 struct kobj_attribute *attr,
 				 const char *buf, size_t count,
 				 enum transparent_hugepage_flag flag)
 {
 	unsigned long value;
-	char *endp;
+	int ret;
 
-	value = simple_strtoul(buf, &endp, 0);
-	if (endp == buf || value > 1)
+	ret = kstrtoul(buf, 10, &value);
+	if (ret < 0)
+		return ret;
+	if (value > 1)
 		return -EINVAL;
 
 	if (value)
_

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

      parent reply	other threads:[~2011-04-13 19:32 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-22  5:45 [PATCH] mm/thp: Use conventional format for boolean attributes Ben Hutchings
2011-04-13 19:04 ` David Rientjes
2011-04-13 19:19   ` Andrew Morton
2011-04-13 19:28     ` David Rientjes
2011-04-13 19:35       ` Andrea Arcangeli
2011-04-14  4:48   ` NeilBrown
2011-04-14 14:29     ` Andrea Arcangeli
2011-04-14 16:57       ` Ben Hutchings
2011-04-14 19:09     ` Andrew Morton
2011-04-14 19:50       ` David Rientjes
2011-04-13 19:31 ` Andrew Morton [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=20110413123122.1adceba6.akpm@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=aarcange@redhat.com \
    --cc=ben@decadent.org.uk \
    --cc=hughd@google.com \
    --cc=jweiner@redhat.com \
    --cc=linux-mm@kvack.org \
    --cc=mel@csn.ul.ie \
    --cc=riel@redhat.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.