libext2fs: replace 'unsigned long' by 'uintptr_t'

This is needed for win64:
    sizeof(unsigned long) != sizeof(void*)

Signed-off-by: Adrien Schildknecht <adriens@google.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
next
Adrien Schildknecht 2016-08-10 17:07:00 -04:00 committed by Theodore Ts'o
parent 5cc6db0c82
commit d4e5abfb1b
8 changed files with 16 additions and 11 deletions

View File

@ -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--;
}

View File

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

View File

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

View File

@ -166,6 +166,8 @@ typedef long __s64;
#endif /* _*_TYPES_H */
#include <stdint.h>
/* endian checking stuff */
#ifndef EXT2_ENDIAN_H_
#define EXT2_ENDIAN_H_

View File

@ -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;
}

View File

@ -95,6 +95,7 @@ static inline struct page * rb_insert_page_cache(struct inode * inode,
#define _LINUX_RBTREE_H
#include <stdlib.h>
#include <stdint.h>
#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;

View File

@ -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)
{

View File

@ -17,6 +17,8 @@ typedef unsigned long long __u64;
typedef __signed__ long long __s64;
#endif
#include <stdint.h> //uintptr_t
/* endian checking stuff */
#ifndef EXT2_ENDIAN_H_
#define EXT2_ENDIAN_H_