From bd918fca02076763269a7cba474d1cff86ec5954 Mon Sep 17 00:00:00 2001 From: Enze Li Date: Wed, 14 Oct 2026 11:11:47 +0800 Subject: [PATCH] mm/hugetlb: use sizeof(buf) in string_get_size() calls Replace the hardcoded 32 with sizeof(buf) at the remaining four call sites, for consistency with the rest of the file. Link: https://lore.kernel.org/20261014031147.444733-1-lienze@kylinos.cn Signed-off-by: Enze Li Signed-off-by: Andrew Morton Acked-by: Muchun Song Cc: Oscar Salvador Cc: David Hildenbrand --- mm/hugetlb.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/mm/hugetlb.c b/mm/hugetlb.c index e3367b319bc5..27e8136b1815 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -3455,7 +3455,7 @@ static void __init hugetlb_hstate_alloc_pages_onenode(struct hstate *h, int nid) if (i == h->max_huge_pages_node[nid]) return; - string_get_size(huge_page_size(h), 1, STRING_UNITS_2, buf, 32); + string_get_size(huge_page_size(h), 1, STRING_UNITS_2, buf, sizeof(buf)); pr_warn("allocating %u of page size %s failed node%d. Only allocated %lu hugepages.\n", h->max_huge_pages_node[nid], buf, nid, i); h->max_huge_pages -= (h->max_huge_pages_node[nid] - i); @@ -3482,7 +3482,7 @@ static void __init hugetlb_hstate_alloc_pages_errcheck(unsigned long allocated, if (allocated < h->max_huge_pages) { char buf[32]; - string_get_size(huge_page_size(h), 1, STRING_UNITS_2, buf, 32); + string_get_size(huge_page_size(h), 1, STRING_UNITS_2, buf, sizeof(buf)); pr_warn("allocating %lu of page size %s failed. Only allocated %lu hugepages.\n", h->max_huge_pages, buf, allocated); h->max_huge_pages = allocated; @@ -3693,7 +3693,7 @@ static void __init report_hugepages(void) for_each_hstate(h) { char buf[32]; - string_get_size(huge_page_size(h), 1, STRING_UNITS_2, buf, 32); + string_get_size(huge_page_size(h), 1, STRING_UNITS_2, buf, sizeof(buf)); pr_info("registered %s page size, pre-allocated %ld pages\n", buf, h->nr_huge_pages); pr_info("%d KiB vmemmap can be freed for a %s page\n", @@ -4205,7 +4205,7 @@ static int __init hugetlb_init(void) char buf[32]; string_get_size(huge_page_size(&default_hstate), - 1, STRING_UNITS_2, buf, 32); + 1, STRING_UNITS_2, buf, sizeof(buf)); pr_warn("Ignoring hugepages=%lu associated with %s page size\n", default_hstate.max_huge_pages, buf); pr_warn("Using hugepages=%lu for number of default huge pages\n",