Re: [PATCH] mm/thp: Use conventional format for boolean attributes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 22 Mar 2011 05:45:11 +0000
Ben Hutchings <ben@xxxxxxxxxxxxxxx> 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@xxxxxxxxxx  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@xxxxxxxxx";> email@xxxxxxxxx </a>


[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]