linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] hugetlb: Fix clang compilation warning
@ 2019-10-16 14:23 Vincenzo Frascino
  2019-10-16 15:21 ` Mike Kravetz
  0 siblings, 1 reply; 3+ messages in thread
From: Vincenzo Frascino @ 2019-10-16 14:23 UTC (permalink / raw)
  To: linux-mm, linux-kernel; +Cc: mike.kravetz, vincenzo.frascino

Building the kernel with a recent version of clang I noticed the warning
below:

mm/hugetlb.c:4055:40: warning: expression does not compute the number of
elements in this array; element type is 'unsigned long', not 'u32'
(aka 'unsigned int') [-Wsizeof-array-div]
        hash = jhash2((u32 *)&key, sizeof(key)/sizeof(u32), 0);
                                          ~~~ ^
mm/hugetlb.c:4049:16: note: array 'key' declared here
        unsigned long key[2];
                      ^
mm/hugetlb.c:4055:40: note: place parentheses around the 'sizeof(u32)'
expression to silence this warning
        hash = jhash2((u32 *)&key, sizeof(key)/sizeof(u32), 0);
                                              ^  CC      fs/ext4/ialloc.o

Fix the warning adding parentheses around the sizeof(u32) expression.

Cc: Mike Kravetz <mike.kravetz@oracle.com>
Signed-off-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
---
 mm/hugetlb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index ef37c85423a5..ce9ff2b35962 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -4052,7 +4052,7 @@ u32 hugetlb_fault_mutex_hash(struct hstate *h, struct address_space *mapping,
 	key[0] = (unsigned long) mapping;
 	key[1] = idx;
 
-	hash = jhash2((u32 *)&key, sizeof(key)/sizeof(u32), 0);
+	hash = jhash2((u32 *)&key, sizeof(key)/(sizeof(u32)), 0);
 
 	return hash & (num_fault_mutexes - 1);
 }
-- 
2.23.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] hugetlb: Fix clang compilation warning
  2019-10-16 14:23 [PATCH] hugetlb: Fix clang compilation warning Vincenzo Frascino
@ 2019-10-16 15:21 ` Mike Kravetz
  2019-10-16 16:41   ` Vincenzo Frascino
  0 siblings, 1 reply; 3+ messages in thread
From: Mike Kravetz @ 2019-10-16 15:21 UTC (permalink / raw)
  To: Vincenzo Frascino, linux-mm, linux-kernel

On 10/16/19 7:23 AM, Vincenzo Frascino wrote:
> Building the kernel with a recent version of clang I noticed the warning
> below:
> 
> mm/hugetlb.c:4055:40: warning: expression does not compute the number of
> elements in this array; element type is 'unsigned long', not 'u32'
> (aka 'unsigned int') [-Wsizeof-array-div]
>         hash = jhash2((u32 *)&key, sizeof(key)/sizeof(u32), 0);
>                                           ~~~ ^
> mm/hugetlb.c:4049:16: note: array 'key' declared here
>         unsigned long key[2];
>                       ^
> mm/hugetlb.c:4055:40: note: place parentheses around the 'sizeof(u32)'
> expression to silence this warning
>         hash = jhash2((u32 *)&key, sizeof(key)/sizeof(u32), 0);
>                                               ^  CC      fs/ext4/ialloc.o
> 
> Fix the warning adding parentheses around the sizeof(u32) expression.
> 
> Cc: Mike Kravetz <mike.kravetz@oracle.com>
> Signed-off-by: Vincenzo Frascino <vincenzo.frascino@arm.com>

Thanks,

However, this is already addressed in Andrew's tree.
https://ozlabs.org/~akpm/mmotm/broken-out/hugetlbfs-hugetlb_fault_mutex_hash-cleanup.patch

-- 
Mike Kravetz

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] hugetlb: Fix clang compilation warning
  2019-10-16 15:21 ` Mike Kravetz
@ 2019-10-16 16:41   ` Vincenzo Frascino
  0 siblings, 0 replies; 3+ messages in thread
From: Vincenzo Frascino @ 2019-10-16 16:41 UTC (permalink / raw)
  To: Mike Kravetz, linux-mm, linux-kernel

Hi Mike,

On 10/16/19 4:21 PM, Mike Kravetz wrote:
> On 10/16/19 7:23 AM, Vincenzo Frascino wrote:
>> Building the kernel with a recent version of clang I noticed the warning
>> below:
>>
>> mm/hugetlb.c:4055:40: warning: expression does not compute the number of
>> elements in this array; element type is 'unsigned long', not 'u32'
>> (aka 'unsigned int') [-Wsizeof-array-div]
>>         hash = jhash2((u32 *)&key, sizeof(key)/sizeof(u32), 0);
>>                                           ~~~ ^
>> mm/hugetlb.c:4049:16: note: array 'key' declared here
>>         unsigned long key[2];
>>                       ^
>> mm/hugetlb.c:4055:40: note: place parentheses around the 'sizeof(u32)'
>> expression to silence this warning
>>         hash = jhash2((u32 *)&key, sizeof(key)/sizeof(u32), 0);
>>                                               ^  CC      fs/ext4/ialloc.o
>>
>> Fix the warning adding parentheses around the sizeof(u32) expression.
>>
>> Cc: Mike Kravetz <mike.kravetz@oracle.com>
>> Signed-off-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
> 
> Thanks,
> 
> However, this is already addressed in Andrew's tree.
> https://ozlabs.org/~akpm/mmotm/broken-out/hugetlbfs-hugetlb_fault_mutex_hash-cleanup.patch
> 

Thank you for pointing this out.

-- 
Regards,
Vincenzo

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-10-16 16:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-16 14:23 [PATCH] hugetlb: Fix clang compilation warning Vincenzo Frascino
2019-10-16 15:21 ` Mike Kravetz
2019-10-16 16:41   ` Vincenzo Frascino

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).