[PATCH] mm/slob: avoid type warning about alignment value

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

 



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@xxxxxxxx>
---
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

--
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=mailto:"dont@xxxxxxxxx";> email@xxxxxxxxx </a>


[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]