Use kstrtobool rather than open coding "on" and "off" parsing in
mm/hugetlb_vmemmap.c, which is more powerful to handle all kinds
of parameters like 'Yy1Nn0' or [oO][NnFf] for "on" and "off".
Signed-off-by: Muchun Song <[email protected]>
Reviewed-by: Mike Kravetz <[email protected]>
Acked-by: David Hildenbrand <[email protected]>
---
mm/hugetlb_vmemmap.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/mm/hugetlb_vmemmap.c b/mm/hugetlb_vmemmap.c
index 6254bb2d4ae5..cc4ec752ec16 100644
--- a/mm/hugetlb_vmemmap.c
+++ b/mm/hugetlb_vmemmap.c
@@ -28,15 +28,15 @@ EXPORT_SYMBOL(hugetlb_optimize_vmemmap_key);
static int __init hugetlb_vmemmap_early_param(char *buf)
{
- if (!buf)
+ bool enable;
+
+ if (kstrtobool(buf, &enable))
return -EINVAL;
- if (!strcmp(buf, "on"))
+ if (enable)
static_branch_enable(&hugetlb_optimize_vmemmap_key);
- else if (!strcmp(buf, "off"))
- static_branch_disable(&hugetlb_optimize_vmemmap_key);
else
- return -EINVAL;
+ static_branch_disable(&hugetlb_optimize_vmemmap_key);
return 0;
}
--
2.11.0
On Mon, May 16, 2022 at 06:22:06PM +0800, Muchun Song wrote:
> Use kstrtobool rather than open coding "on" and "off" parsing in
> mm/hugetlb_vmemmap.c, which is more powerful to handle all kinds
> of parameters like 'Yy1Nn0' or [oO][NnFf] for "on" and "off".
>
> Signed-off-by: Muchun Song <[email protected]>
> Reviewed-by: Mike Kravetz <[email protected]>
> Acked-by: David Hildenbrand <[email protected]>
Reviewed-by: Oscar Salvador <[email protected]>
--
Oscar Salvador
SUSE Labs