From d4e5abfb1bb990a029005c1a801961fc1a0ba866 Mon Sep 17 00:00:00 2001 From: Adrien Schildknecht Date: Wed, 10 Aug 2016 17:07:00 -0400 Subject: [PATCH] libext2fs: replace 'unsigned long' by 'uintptr_t' This is needed for win64: sizeof(unsigned long) != sizeof(void*) Signed-off-by: Adrien Schildknecht Signed-off-by: Theodore Ts'o --- lib/ext2fs/bitops.c | 2 +- lib/ext2fs/blkmap64_ba.c | 4 ++-- lib/ext2fs/crc32c.c | 4 ++-- lib/ext2fs/ext2_types.h.in | 2 ++ lib/ext2fs/inline.c | 2 +- lib/ext2fs/rbtree.h | 7 ++++--- lib/ext2fs/unix_io.c | 4 ++-- util/android_types.h | 2 ++ 8 files changed, 16 insertions(+), 11 deletions(-) diff --git a/lib/ext2fs/bitops.c b/lib/ext2fs/bitops.c index 8e4c05c4..833d1e97 100644 --- a/lib/ext2fs/bitops.c +++ b/lib/ext2fs/bitops.c @@ -138,7 +138,7 @@ unsigned int ext2fs_bitcount(const void *addr, unsigned int nbytes) const __u32 *p; unsigned int res = 0; - while (((((unsigned long) cp) & 3) != 0) && (nbytes > 0)) { + while (((((uintptr_t) cp) & 3) != 0) && (nbytes > 0)) { res += popcount8(*cp++); nbytes--; } diff --git a/lib/ext2fs/blkmap64_ba.c b/lib/ext2fs/blkmap64_ba.c index 4671c50d..3707a61e 100644 --- a/lib/ext2fs/blkmap64_ba.c +++ b/lib/ext2fs/blkmap64_ba.c @@ -349,7 +349,7 @@ static errcode_t ba_find_first_zero(ext2fs_generic_bitmap bitmap, pos = ((unsigned char *)bp->bitarray) + (bitpos >> 3); /* scan bytes until 8-byte (64-bit) aligned */ - while (count >= 8 && (((unsigned long)pos) & 0x07)) { + while (count >= 8 && (((uintptr_t)pos) & 0x07)) { if (*pos != 0xff) { byte_found = 1; break; @@ -423,7 +423,7 @@ static errcode_t ba_find_first_set(ext2fs_generic_bitmap bitmap, pos = ((unsigned char *)bp->bitarray) + (bitpos >> 3); /* scan bytes until 8-byte (64-bit) aligned */ - while (count >= 8 && (((unsigned long)pos) & 0x07)) { + while (count >= 8 && (((uintptr_t)pos) & 0x07)) { if (*pos != 0) { byte_found = 1; break; diff --git a/lib/ext2fs/crc32c.c b/lib/ext2fs/crc32c.c index 624ad776..8ad0050f 100644 --- a/lib/ext2fs/crc32c.c +++ b/lib/ext2fs/crc32c.c @@ -97,10 +97,10 @@ crc32_body(uint32_t crc, unsigned char const *buf, size_t len, uint32_t q; /* Align it */ - if (unlikely((long)buf & 3 && len)) { + if (unlikely((uintptr_t)buf & 3 && len)) { do { DO_CRC(*buf++); - } while ((--len) && ((long)buf)&3); + } while ((--len) && ((uintptr_t)buf)&3); } # if CRC_LE_BITS == 32 diff --git a/lib/ext2fs/ext2_types.h.in b/lib/ext2fs/ext2_types.h.in index fd572314..07adc64a 100644 --- a/lib/ext2fs/ext2_types.h.in +++ b/lib/ext2fs/ext2_types.h.in @@ -166,6 +166,8 @@ typedef long __s64; #endif /* _*_TYPES_H */ +#include + /* endian checking stuff */ #ifndef EXT2_ENDIAN_H_ #define EXT2_ENDIAN_H_ diff --git a/lib/ext2fs/inline.c b/lib/ext2fs/inline.c index 8f403942..ae2ae6e4 100644 --- a/lib/ext2fs/inline.c +++ b/lib/ext2fs/inline.c @@ -70,7 +70,7 @@ errcode_t ext2fs_get_memalign(unsigned long size, else #endif *p = malloc(size); - if ((unsigned long) *p & (align - 1)) { + if ((uintptr_t) *p & (align - 1)) { free(*p); *p = 0; } diff --git a/lib/ext2fs/rbtree.h b/lib/ext2fs/rbtree.h index 6aaa941f..b767a90b 100644 --- a/lib/ext2fs/rbtree.h +++ b/lib/ext2fs/rbtree.h @@ -95,6 +95,7 @@ static inline struct page * rb_insert_page_cache(struct inode * inode, #define _LINUX_RBTREE_H #include +#include #undef offsetof #ifdef __compiler_offsetof @@ -109,7 +110,7 @@ static inline struct page * rb_insert_page_cache(struct inode * inode, struct rb_node { - unsigned long rb_parent_color; + uintptr_t rb_parent_color; #define RB_RED 0 #define RB_BLACK 1 struct rb_node *rb_right; @@ -132,7 +133,7 @@ struct rb_root static inline void ext2fs_rb_set_parent(struct rb_node *rb, struct rb_node *p) { - rb->rb_parent_color = (rb->rb_parent_color & 3) | (unsigned long)p; + rb->rb_parent_color = (rb->rb_parent_color & 3) | (uintptr_t)p; } static inline void ext2fs_rb_set_color(struct rb_node *rb, int color) { @@ -182,7 +183,7 @@ static inline void ext2fs_rb_link_node(struct rb_node * node, struct rb_node * parent, struct rb_node ** rb_link) { - node->rb_parent_color = (unsigned long )parent; + node->rb_parent_color = (uintptr_t)parent; node->rb_left = node->rb_right = NULL; *rb_link = node; diff --git a/lib/ext2fs/unix_io.c b/lib/ext2fs/unix_io.c index 6c6e6d5d..0c9e6bf2 100644 --- a/lib/ext2fs/unix_io.c +++ b/lib/ext2fs/unix_io.c @@ -103,8 +103,8 @@ struct unix_private_data { struct struct_io_stats io_stats; }; -#define IS_ALIGNED(n, align) ((((unsigned long) n) & \ - ((unsigned long) ((align)-1))) == 0) +#define IS_ALIGNED(n, align) ((((uintptr_t) n) & \ + ((uintptr_t) ((align)-1))) == 0) static errcode_t unix_get_stats(io_channel channel, io_stats *stats) { diff --git a/util/android_types.h b/util/android_types.h index 2b3e78f6..9c3f7149 100644 --- a/util/android_types.h +++ b/util/android_types.h @@ -17,6 +17,8 @@ typedef unsigned long long __u64; typedef __signed__ long long __s64; #endif +#include //uintptr_t + /* endian checking stuff */ #ifndef EXT2_ENDIAN_H_ #define EXT2_ENDIAN_H_