Re: [mmotm:master 301/497] mm/hugetlb.c:2812:4: warning: format '%d' expects argument of type 'int', but argument 4 has type 'long unsigned int'

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Aug 14, 2015 at 07:37:39AM +0800, kbuild test robot wrote:
> tree:   git://git.cmpxchg.org/linux-mmotm.git master
> head:   f6a6014bf6b3c724cff30194681f219ac230c898
> commit: b1e17e02f94bd2dec7547553e3cc5330f497193c [301/497] mm: hugetlb: proc: add HugetlbPages field to /proc/PID/status
> config: i386-randconfig-i1-201532 (attached as .config)
> reproduce:
>   git checkout b1e17e02f94bd2dec7547553e3cc5330f497193c
>   # save the attached .config to linux build tree
>   make ARCH=i386 
> 
> All warnings (new ones prefixed by >>):
> 
>    mm/hugetlb.c: In function 'hugetlb_report_usage':
> >> mm/hugetlb.c:2812:4: warning: format '%d' expects argument of type 'int', but argument 4 has type 'long unsigned int' [-Wformat=]
>        huge_page_size(&hstates[i]) >> 10);
>        ^
> 
> vim +2812 mm/hugetlb.c
> 
>   2796		unsigned long total_usage = 0;
>   2797	
>   2798		for (i = 0; i < HUGE_MAX_HSTATE; i++) {
>   2799			total_usage += atomic_long_read(&mm->hugetlb_usage.count[i]) *
>   2800				(huge_page_size(&hstates[i]) >> 10);
>   2801		}
>   2802	
>   2803		seq_printf(m, "HugetlbPages:\t%8lu kB (", total_usage);
>   2804		for (i = 0; i < HUGE_MAX_HSTATE; i++) {
>   2805			if (huge_page_order(&hstates[i]) == 0)
>   2806				break;
>   2807			if (i > 0)
>   2808				seq_puts(m, " ");
>   2809	
>   2810			seq_printf(m, "%ldx%dkB",
>   2811				atomic_long_read(&mm->hugetlb_usage.count[i]),
> > 2812				huge_page_size(&hstates[i]) >> 10);

huge_page_size() return type unsigned long, so I should've used "%lu".

Thanks,
Naoya Horiguchi
---
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index 2338c9713b7a..92ecd41c5e5a 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -2579,7 +2579,7 @@ void hugetlb_report_usage(struct seq_file *m, struct mm_struct *mm)
 		if (i > 0)
 			seq_puts(m, " ");
 
-		seq_printf(m, "%ld*%dkB",
+		seq_printf(m, "%ld*%lukB",
 			atomic_long_read(&mm->hugetlb_usage.count[i]),
 			huge_page_size(&hstates[i]) >> 10);
 	}

--
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/ .
Don't email: <a href



[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]