* [PATCH v1] tools/vm/slabinfo.c: fix sign-compare warning @ 2018-08-24 9:32 Naoya Horiguchi 2018-08-26 2:21 ` Matthew Wilcox 0 siblings, 1 reply; 3+ messages in thread From: Naoya Horiguchi @ 2018-08-24 9:32 UTC (permalink / raw) To: linux-mm, linux-kernel; +Cc: Andrew Morton Currently we get the following compiler warning: slabinfo.c:854:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] if (s->object_size < min_objsize) ^ due to the mismatch of signed/unsigned comparison. ->object_size and ->slab_size are never expected to be negative, so let's define them as unsigned int. Signed-off-by: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com> --- tools/vm/slabinfo.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git v4.18-mmotm-2018-08-17-15-48/tools/vm/slabinfo.c v4.18-mmotm-2018-08-17-15-48_patched/tools/vm/slabinfo.c index f82c2ea..eebeeb1 100644 --- v4.18-mmotm-2018-08-17-15-48/tools/vm/slabinfo.c +++ v4.18-mmotm-2018-08-17-15-48_patched/tools/vm/slabinfo.c @@ -30,9 +30,10 @@ struct slabinfo { int alias; int refs; int aliases, align, cache_dma, cpu_slabs, destroy_by_rcu; - int hwcache_align, object_size, objs_per_slab; - int sanity_checks, slab_size, store_user, trace; + int hwcache_align, objs_per_slab; + int sanity_checks, store_user, trace; int order, poison, reclaim_account, red_zone; + unsigned int object_size, slab_size; unsigned long partial, objects, slabs, objects_partial, objects_total; unsigned long alloc_fastpath, alloc_slowpath; unsigned long free_fastpath, free_slowpath; -- 2.7.0 ^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v1] tools/vm/slabinfo.c: fix sign-compare warning 2018-08-24 9:32 [PATCH v1] tools/vm/slabinfo.c: fix sign-compare warning Naoya Horiguchi @ 2018-08-26 2:21 ` Matthew Wilcox 2018-08-26 23:49 ` [PATCH v2] " Naoya Horiguchi 0 siblings, 1 reply; 3+ messages in thread From: Matthew Wilcox @ 2018-08-26 2:21 UTC (permalink / raw) To: Naoya Horiguchi; +Cc: linux-mm, linux-kernel, Andrew Morton On Fri, Aug 24, 2018 at 06:32:14PM +0900, Naoya Horiguchi wrote: > - int hwcache_align, object_size, objs_per_slab; > - int sanity_checks, slab_size, store_user, trace; > + int hwcache_align, objs_per_slab; > + int sanity_checks, store_user, trace; > int order, poison, reclaim_account, red_zone; > + unsigned int object_size, slab_size; Surely hwcache_align and objs_per_slab can't be negative either? Nor the other three. So maybe convert all seven of these variables to unsigned int? ^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH v2] tools/vm/slabinfo.c: fix sign-compare warning 2018-08-26 2:21 ` Matthew Wilcox @ 2018-08-26 23:49 ` Naoya Horiguchi 0 siblings, 0 replies; 3+ messages in thread From: Naoya Horiguchi @ 2018-08-26 23:49 UTC (permalink / raw) To: Matthew Wilcox; +Cc: linux-mm, linux-kernel, Andrew Morton On Sat, Aug 25, 2018 at 07:21:14PM -0700, Matthew Wilcox wrote: > On Fri, Aug 24, 2018 at 06:32:14PM +0900, Naoya Horiguchi wrote: > > - int hwcache_align, object_size, objs_per_slab; > > - int sanity_checks, slab_size, store_user, trace; > > + int hwcache_align, objs_per_slab; > > + int sanity_checks, store_user, trace; > > int order, poison, reclaim_account, red_zone; > > + unsigned int object_size, slab_size; > > Surely hwcache_align and objs_per_slab can't be negative either? > Nor the other three. So maybe convert all seven of these variables to > unsigned int? > Fair enough, I update the patch. Thanks for the comment. - Naoya --- From 25e19ce711cdb4aa5c4f1a04784017af48616e5f Mon Sep 17 00:00:00 2001 From: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com> Date: Fri, 24 Aug 2018 18:22:40 +0900 Subject: [PATCH v2] tools/vm/slabinfo.c: fix sign-compare warning Currently we get the following compiler warning: slabinfo.c:854:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] if (s->object_size < min_objsize) ^ due to the mismatch of signed/unsigned comparison. ->object_size and ->slab_size are never expected to be negative, so let's define them as unsigned int. Signed-off-by: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com> --- tools/vm/slabinfo.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/vm/slabinfo.c b/tools/vm/slabinfo.c index f82c2eaa859d..334b16db0ebb 100644 --- a/tools/vm/slabinfo.c +++ b/tools/vm/slabinfo.c @@ -30,8 +30,8 @@ struct slabinfo { int alias; int refs; int aliases, align, cache_dma, cpu_slabs, destroy_by_rcu; - int hwcache_align, object_size, objs_per_slab; - int sanity_checks, slab_size, store_user, trace; + unsigned int hwcache_align, object_size, objs_per_slab; + unsigned int sanity_checks, slab_size, store_user, trace; int order, poison, reclaim_account, red_zone; unsigned long partial, objects, slabs, objects_partial, objects_total; unsigned long alloc_fastpath, alloc_slowpath; -- 2.7.4 ^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-08-26 23:53 UTC | newest] Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2018-08-24 9:32 [PATCH v1] tools/vm/slabinfo.c: fix sign-compare warning Naoya Horiguchi 2018-08-26 2:21 ` Matthew Wilcox 2018-08-26 23:49 ` [PATCH v2] " Naoya Horiguchi
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).