On Mon, 16 Apr 2012 16:14:47 +0530 "Aneesh Kumar K.V" <aneesh.kumar@xxxxxxxxxxxxxxxxxx> wrote: > +#ifdef CONFIG_MEM_RES_CTLR_HUGETLB > +static char *mem_fmt(char *buf, unsigned long n) > +{ > + if (n >= (1UL << 30)) > + sprintf(buf, "%luGB", n >> 30); > + else if (n >= (1UL << 20)) > + sprintf(buf, "%luMB", n >> 20); > + else > + sprintf(buf, "%luKB", n >> 10); > + return buf; > +} > + > +int __init mem_cgroup_hugetlb_file_init(int idx) > +{ > + char buf[32]; > + struct cftype *cft; > + struct hstate *h = &hstates[idx]; > + > + /* format the size */ > + mem_fmt(buf, huge_page_size(h)); The sprintf() into a fixed-sized buffer is a bit ugly. I didn't check it for possible overflows because 32 looks like "enough". Actually too much. Oh well, it's hard to avoid. But using scnprintf() would prevent nasty accidents. -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@xxxxxxxxx. For more info on Linux MM, see: http://www.linux-mm.org/ . Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/ Don't email: <a href=mailto:"dont@xxxxxxxxx"> email@xxxxxxxxx </a>