From 7cd23fb20722d8101fdfb4017f826a86663776bc Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Sat, 11 Feb 2012 21:17:04 +0100 Subject: [PATCH] Fastbuf: Get rid of ->is_fastbuf typechecking hack ... it breaks C99 aliasing rules and GCC rightfully warns about it. If we ever want to do such type checking, we might use #define CAST(f) ((f)->is_fastbuf, (struct xxxx *)(f)) but I guess it is of little use anyway, so I am removing it. --- charset/fb-charconv.c | 2 +- ucw/fastbuf.h | 2 -- ucw/fb-atomic.c | 1 + ucw/fb-direct.c | 2 +- ucw/fb-file.c | 2 +- ucw/fb-grow.c | 2 +- ucw/fb-limfd.c | 2 +- ucw/fb-mem.c | 2 +- ucw/fb-mmap.c | 2 +- ucw/fb-pool.c | 2 +- ucw/fb-socket.c | 2 +- 11 files changed, 10 insertions(+), 11 deletions(-) diff --git a/charset/fb-charconv.c b/charset/fb-charconv.c index c119a1be..1289213e 100644 --- a/charset/fb-charconv.c +++ b/charset/fb-charconv.c @@ -20,7 +20,7 @@ struct fb_charconv { struct conv_context ctxt; byte buf[BUFSIZE]; }; -#define FB_CC(f) ((struct fb_charconv *)(f)->is_fastbuf) +#define FB_CC(f) ((struct fb_charconv *)(f)) static void fb_cc_spout(struct fastbuf *f) diff --git a/ucw/fastbuf.h b/ucw/fastbuf.h index 4e3199d8..6d02ac03 100644 --- a/ucw/fastbuf.h +++ b/ucw/fastbuf.h @@ -129,7 +129,6 @@ * for how it works. **/ struct fastbuf { - byte is_fastbuf[0]; /* Dummy field for checking of type casts */ byte *bptr, *bstop; /* State of the buffer */ byte *buffer, *bufend; /* Start and end of the buffer */ char *name; /* File name (used for error messages) */ @@ -445,7 +444,6 @@ struct fb_atomic { byte *expected_max_bptr; uns slack_size; }; -#define FB_ATOMIC(f) ((struct fb_atomic *)(f)->is_fastbuf) /** * Open an atomic fastbuf. diff --git a/ucw/fb-atomic.c b/ucw/fb-atomic.c index aef0018a..8cee3087 100644 --- a/ucw/fb-atomic.c +++ b/ucw/fb-atomic.c @@ -34,6 +34,7 @@ static void CONSTRUCTOR fbatomic_init_config(void) #endif +#define FB_ATOMIC(f) ((struct fb_atomic *)(f)) #define TRACE(m...) do { if(trace) msg(L_DEBUG, "FB_ATOMIC: " m); } while(0) struct fb_atomic_file { diff --git a/ucw/fb-direct.c b/ucw/fb-direct.c index 9dff847d..74a85c67 100644 --- a/ucw/fb-direct.c +++ b/ucw/fb-direct.c @@ -57,7 +57,7 @@ struct fb_direct { enum fbdir_mode mode; byte name[0]; }; -#define FB_DIRECT(f) ((struct fb_direct *)(f)->is_fastbuf) +#define FB_DIRECT(f) ((struct fb_direct *)(f)) #ifndef TEST uns fbdir_cheat; diff --git a/ucw/fb-file.c b/ucw/fb-file.c index 6151e59c..bfa38a9e 100644 --- a/ucw/fb-file.c +++ b/ucw/fb-file.c @@ -25,7 +25,7 @@ struct fb_file { ucw_off_t wpos; /* Real file position */ uns wlen; /* Window size */ }; -#define FB_FILE(f) ((struct fb_file *)(f)->is_fastbuf) +#define FB_FILE(f) ((struct fb_file *)(f)) #define FB_BUFFER(f) (byte *)(FB_FILE(f) + 1) static int diff --git a/ucw/fb-grow.c b/ucw/fb-grow.c index f6131536..927fe96a 100644 --- a/ucw/fb-grow.c +++ b/ucw/fb-grow.c @@ -19,7 +19,7 @@ struct fb_gbuf { struct mempool *mp; byte *end; }; -#define FB_GBUF(f) ((struct fb_gbuf *)(f)->is_fastbuf) +#define FB_GBUF(f) ((struct fb_gbuf *)(f)) static int fbgrow_refill(struct fastbuf *b) { diff --git a/ucw/fb-limfd.c b/ucw/fb-limfd.c index 76e728a4..0ce80c6a 100644 --- a/ucw/fb-limfd.c +++ b/ucw/fb-limfd.c @@ -17,7 +17,7 @@ struct fb_limfd { int fd; /* File descriptor */ int limit; }; -#define FB_LIMFD(f) ((struct fb_limfd *)(f)->is_fastbuf) +#define FB_LIMFD(f) ((struct fb_limfd *)(f)) #define FB_BUFFER(f) (byte *)(FB_LIMFD(f) + 1) static int diff --git a/ucw/fb-mem.c b/ucw/fb-mem.c index 92e3b497..2752c240 100644 --- a/ucw/fb-mem.c +++ b/ucw/fb-mem.c @@ -30,7 +30,7 @@ struct fb_mem { struct memstream *stream; struct msblock *block; }; -#define FB_MEM(f) ((struct fb_mem *)(f)->is_fastbuf) +#define FB_MEM(f) ((struct fb_mem *)(f)) static int fbmem_refill(struct fastbuf *f) diff --git a/ucw/fb-mmap.c b/ucw/fb-mmap.c index 9e030f64..b402b07c 100644 --- a/ucw/fb-mmap.c +++ b/ucw/fb-mmap.c @@ -47,7 +47,7 @@ struct fb_mmap { uns window_size; int mode; }; -#define FB_MMAP(f) ((struct fb_mmap *)(f)->is_fastbuf) +#define FB_MMAP(f) ((struct fb_mmap *)(f)) static void bfmm_map_window(struct fastbuf *f) diff --git a/ucw/fb-pool.c b/ucw/fb-pool.c index 17a9c6dc..e3095c73 100644 --- a/ucw/fb-pool.c +++ b/ucw/fb-pool.c @@ -14,7 +14,7 @@ #include #include -#define FB_POOL(f) ((struct fbpool *)(f)->is_fastbuf) +#define FB_POOL(f) ((struct fbpool *)(f)) static void fbpool_spout(struct fastbuf *b) diff --git a/ucw/fb-socket.c b/ucw/fb-socket.c index 84395f09..3f44cbcb 100644 --- a/ucw/fb-socket.c +++ b/ucw/fb-socket.c @@ -22,7 +22,7 @@ struct fb_sock { byte buf[0]; }; -#define FB_SOCK(f) ((struct fb_sock *)(f)->is_fastbuf) +#define FB_SOCK(f) ((struct fb_sock *)(f)) static int fbs_refill(struct fastbuf *f) -- 2.39.2