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 <lienze@kylinos.cn>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Acked-by: Muchun Song <muchun.song@linux.dev>
Cc: Oscar Salvador <osalvador@suse.de>
Cc: David Hildenbrand <david@kernel.org>
This commit is contained in:
Enze Li 2026-10-14 11:11:47 +08:00 committed by Andrew Morton
parent 4cd78a2dcf
commit bd918fca02

View File

@ -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",