From: Martin Mares Date: Wed, 2 Mar 2005 21:48:47 +0000 (+0000) Subject: Fix incorrect pointer casts. X-Git-Tag: holmes-import~818 X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=e320e14ace7728b7f4c3b47c887ff9aa1934dbae;p=libucw.git Fix incorrect pointer casts. --- diff --git a/lib/lib.h b/lib/lib.h index f81e3589..2102dd43 100644 --- a/lib/lib.h +++ b/lib/lib.h @@ -1,7 +1,7 @@ /* * The UCW Library -- Miscellaneous Functions * - * (c) 1997--2004 Martin Mares + * (c) 1997--2005 Martin Mares * (c) 2005 Tomas Valla * * This software may be freely distributed and used according to the terms @@ -24,7 +24,7 @@ #define SKIP_BACK(s, i, p) ((s *)((char *)p - OFFSETOF(s, i))) #define ALIGN(s, a) (((s)+a-1)&~(a-1)) #define ALIGN_PTR(p, s) ((addr_int_t)(p) % (s) ? (typeof(p))((addr_int_t)(p) + (s) - (addr_int_t)(p) % (s)) : (p)) -#define UNALIGNED_PART(ptr, type) (((long) (ptr)) % sizeof(type)) +#define UNALIGNED_PART(ptr, type) (((addr_int_t) (ptr)) % sizeof(type)) /* Some other macros */ diff --git a/lib/mempool.c b/lib/mempool.c index b0c03eed..410fa16b 100644 --- a/lib/mempool.c +++ b/lib/mempool.c @@ -69,7 +69,7 @@ mp_alloc(struct mempool *p, uns s) { if (s <= p->threshold) { - byte *x = (byte *)(((uns) p->free + POOL_ALIGN - 1) & ~(POOL_ALIGN - 1)); + byte *x = (byte *)(((addr_int_t) p->free + POOL_ALIGN - 1) & ~(addr_int_t)(POOL_ALIGN - 1)); if (x + s > p->last) { struct memchunk *c; diff --git a/lib/mempool.h b/lib/mempool.h index 7290c256..98d46e57 100644 --- a/lib/mempool.h +++ b/lib/mempool.h @@ -29,7 +29,7 @@ void *mp_alloc_zero(struct mempool *, uns); static inline void *mp_alloc_fast(struct mempool *p, uns l) { - byte *f = (void *) (((uns) p->free + POOL_ALIGN - 1) & ~(POOL_ALIGN - 1)); + byte *f = (void *) (((addr_int_t) p->free + POOL_ALIGN - 1) & ~(addr_int_t)(POOL_ALIGN - 1)); byte *ee = f + l; if (ee > p->last) return mp_alloc(p, l);