* [PATCH -next] mm/hugetlb_cgroup: fix -Wformat-truncation warning
@ 2025-12-22 7:23 Xiu Jianfeng
2025-12-22 19:15 ` Andrew Morton
0 siblings, 1 reply; 3+ messages in thread
From: Xiu Jianfeng @ 2025-12-22 7:23 UTC (permalink / raw)
To: muchun.song, osalvador, david, akpm; +Cc: linux-mm, linux-kernel
From: Xiu Jianfeng <xiujianfeng@huawei.com>
A false-positive compile warnings with -Wformat-trucation was introduced
by commit 47179fe03588 ("mm/hugetlb_cgroup: prepare cftypes based
on template") on arch s390. Suppress it by replacing snprintf() with
scnprintf().
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202512212332.9lFRbgdS-lkp@intel.com/
Signed-off-by: Xiu Jianfeng <xiujianfeng@huawei.com>
---
mm/hugetlb_cgroup.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mm/hugetlb_cgroup.c b/mm/hugetlb_cgroup.c
index 58e895f3899a..7144d7d555eb 100644
--- a/mm/hugetlb_cgroup.c
+++ b/mm/hugetlb_cgroup.c
@@ -822,7 +822,7 @@ hugetlb_cgroup_cfttypes_init(struct hstate *h, struct cftype *cft,
for (i = 0; i < tmpl_size; cft++, tmpl++, i++) {
*cft = *tmpl;
/* rebuild the name */
- snprintf(cft->name, MAX_CFTYPE_NAME, "%s.%s", buf, tmpl->name);
+ scnprintf(cft->name, MAX_CFTYPE_NAME, "%s.%s", buf, tmpl->name);
/* rebuild the private */
cft->private = MEMFILE_PRIVATE(idx, tmpl->private);
/* rebuild the file_offset */
--
2.43.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH -next] mm/hugetlb_cgroup: fix -Wformat-truncation warning
2025-12-22 7:23 [PATCH -next] mm/hugetlb_cgroup: fix -Wformat-truncation warning Xiu Jianfeng
@ 2025-12-22 19:15 ` Andrew Morton
2025-12-23 1:18 ` Xiujianfeng
0 siblings, 1 reply; 3+ messages in thread
From: Andrew Morton @ 2025-12-22 19:15 UTC (permalink / raw)
To: Xiu Jianfeng; +Cc: muchun.song, osalvador, david, linux-mm, linux-kernel
On Mon, 22 Dec 2025 07:23:59 +0000 Xiu Jianfeng <xiujianfeng@huaweicloud.com> wrote:
> A false-positive compile warnings with -Wformat-trucation was introduced
> by commit 47179fe03588 ("mm/hugetlb_cgroup: prepare cftypes based
> on template") on arch s390. Suppress it by replacing snprintf() with
> scnprintf().
Thanks.
Let's quote that error message in the changelog and include the Fixes:.
From: Xiu Jianfeng <xiujianfeng@huawei.com>
Subject: mm/hugetlb_cgroup: fix -Wformat-truncation warning
Date: Mon, 22 Dec 2025 07:23:59 +0000
A false-positive compile warnings with -Wformat-trucation was introduced
by commit 47179fe03588 ("mm/hugetlb_cgroup: prepare cftypes based on
template") on arch s390. Suppress it by replacing snprintf() with
scnprintf().
mm/hugetlb_cgroup.c: In function 'hugetlb_cgroup_file_init':
mm/hugetlb_cgroup.c:829:44: warning: '%s' directive output may be truncated writing up to 1623 bytes into a region of size between 32 and 63 [-Wformat-truncation=]
829 | snprintf(cft->name, MAX_CFTYPE_NAME, "%s.%s", buf, tmpl->name);
| ^~
Link: https://lkml.kernel.org/r/20251222072359.3626182-1-xiujianfeng@huaweicloud.com
Fixes: 47179fe03588 ("mm/hugetlb_cgroup: prepare cftypes based on template")
Signed-off-by: Xiu Jianfeng <xiujianfeng@huawei.com>
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202512212332.9lFRbgdS-lkp@intel.com/
Cc: "David Hildenbrand (Red Hat)" <david@kernel.org>
Cc: Muchun Song <muchun.song@linux.dev>
Cc: Oscar Salvador <osalvador@suse.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---
mm/hugetlb_cgroup.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--- a/mm/hugetlb_cgroup.c~mm-hugetlb_cgroup-fix-wformat-truncation-warning
+++ a/mm/hugetlb_cgroup.c
@@ -822,7 +822,7 @@ hugetlb_cgroup_cfttypes_init(struct hsta
for (i = 0; i < tmpl_size; cft++, tmpl++, i++) {
*cft = *tmpl;
/* rebuild the name */
- snprintf(cft->name, MAX_CFTYPE_NAME, "%s.%s", buf, tmpl->name);
+ scnprintf(cft->name, MAX_CFTYPE_NAME, "%s.%s", buf, tmpl->name);
/* rebuild the private */
cft->private = MEMFILE_PRIVATE(idx, tmpl->private);
/* rebuild the file_offset */
_
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH -next] mm/hugetlb_cgroup: fix -Wformat-truncation warning
2025-12-22 19:15 ` Andrew Morton
@ 2025-12-23 1:18 ` Xiujianfeng
0 siblings, 0 replies; 3+ messages in thread
From: Xiujianfeng @ 2025-12-23 1:18 UTC (permalink / raw)
To: Andrew Morton; +Cc: muchun.song, osalvador, david, linux-mm, linux-kernel
On 12/23/2025 3:15 AM, Andrew Morton wrote:
> On Mon, 22 Dec 2025 07:23:59 +0000 Xiu Jianfeng <xiujianfeng@huaweicloud.com> wrote:
>
>> A false-positive compile warnings with -Wformat-trucation was introduced
>> by commit 47179fe03588 ("mm/hugetlb_cgroup: prepare cftypes based
>> on template") on arch s390. Suppress it by replacing snprintf() with
>> scnprintf().
>
> Thanks.
>
> Let's quote that error message in the changelog and include the Fixes:.
Thanks, Andrew.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-12-23 1:18 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-12-22 7:23 [PATCH -next] mm/hugetlb_cgroup: fix -Wformat-truncation warning Xiu Jianfeng
2025-12-22 19:15 ` Andrew Morton
2025-12-23 1:18 ` Xiujianfeng
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox