}
#ifdef CONFIG_MEM_RES_CTLR_HUGETLB
-static char *mem_fmt(char *buf, unsigned long n)
+static char *mem_fmt(char *buf, int size, unsigned long hsize)
{
- if (n >= (1UL << 30))
- sprintf(buf, "%luGB", n >> 30);
- else if (n >= (1UL << 20))
- sprintf(buf, "%luMB", n >> 20);
+ if (hsize >= (1UL << 30))
+ scnprintf(buf, size, "%luGB", hsize >> 30);
+ else if (hsize >= (1UL << 20))
+ scnprintf(buf, size, "%luMB", hsize >> 20);
else
- sprintf(buf, "%luKB", n >> 10);
+ scnprintf(buf, size, "%luKB", hsize >> 10);
return buf;
}
struct hstate *h = &hstates[idx];
/* format the size */
- mem_fmt(buf, huge_page_size(h));
+ mem_fmt(buf, 32, huge_page_size(h));
/* Add the limit file */
cft = &h->mem_cgroup_files[0];