public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mm/slob: avoid type warning about alignment value
@ 2012-07-10 20:55 Arnd Bergmann
  2012-07-11  1:18 ` David Rientjes
  0 siblings, 1 reply; 4+ messages in thread
From: Arnd Bergmann @ 2012-07-10 20:55 UTC (permalink / raw)
  To: Pekka Enberg
  Cc: Christoph Lameter, linux-kernel@vger.kernel.org, Matt Mackall,
	linux-mm

The types for ARCH_KMALLOC_MINALIGN and ARCH_SLAB_MINALIGN are not always
the same, as seen by building ARM collie_defconfig:

mm/slob.c: In function 'kfree':
mm/slob.c:482:153: warning: comparison of distinct pointer types lacks a cast
mm/slob.c: In function 'ksize':
mm/slob.c:501:153: warning: comparison of distinct pointer types lacks a cast

Using max_t to find the correct alignment avoids the warning.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
diff --git a/mm/slob.c b/mm/slob.c
index 95d1c7d..51d6a27 100644
--- a/mm/slob.c
+++ b/mm/slob.c
@@ -426,7 +426,7 @@ out:
 void *__kmalloc_node(size_t size, gfp_t gfp, int node)
 {
 	unsigned int *m;
-	int align = max(ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
+	int align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
 	void *ret;
 
 	gfp &= gfp_allowed_mask;
@@ -479,7 +479,7 @@ void kfree(const void *block)
 
 	sp = virt_to_page(block);
 	if (PageSlab(sp)) {
-		int align = max(ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
+		int align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
 		unsigned int *m = (unsigned int *)(block - align);
 		slob_free(m, *m + align);
 	} else
@@ -498,7 +498,7 @@ size_t ksize(const void *block)
 
 	sp = virt_to_page(block);
 	if (PageSlab(sp)) {
-		int align = max(ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
+		int align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
 		unsigned int *m = (unsigned int *)(block - align);
 		return SLOB_UNITS(*m) * SLOB_UNIT;
 	} else

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

end of thread, other threads:[~2012-07-11 20:43 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-07-10 20:55 [PATCH] mm/slob: avoid type warning about alignment value Arnd Bergmann
2012-07-11  1:18 ` David Rientjes
2012-07-11  6:39   ` Arnd Bergmann
2012-07-11 20:42     ` David Rientjes

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox