]> mj.ucw.cz Git - libucw.git/commitdiff
Fastbuf: Get rid of ->is_fastbuf typechecking hack
authorMartin Mares <mj@ucw.cz>
Sat, 11 Feb 2012 20:17:04 +0000 (21:17 +0100)
committerMartin Mares <mj@ucw.cz>
Sat, 11 Feb 2012 20:17:04 +0000 (21:17 +0100)
... 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
ucw/fastbuf.h
ucw/fb-atomic.c
ucw/fb-direct.c
ucw/fb-file.c
ucw/fb-grow.c
ucw/fb-limfd.c
ucw/fb-mem.c
ucw/fb-mmap.c
ucw/fb-pool.c
ucw/fb-socket.c

index c119a1bea87d55a3ee7855434d9b7b56263bfe40..1289213ef1541b1444004423ea642451c961544d 100644 (file)
@@ -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)
index 4e3199d8bf567973ffc04a4de2f134c908f89eec..6d02ac037b47701c3da597c2b88154946d3ce842 100644 (file)
  * 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.
index aef0018ac03ddaeca722b5a5594348de96139ada..8cee3087f96ae63644271a181b132f7da4152963 100644 (file)
@@ -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 {
index 9dff847dc30d321ac14cfa3684883139c56a77b8..74a85c67b2f425ccfa89599241adb3401bd5dd44 100644 (file)
@@ -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;
index 6151e59c14c73ff258c3669dea482408fe4ab31f..bfa38a9eae4ad811470bec674d26a53bfb8e5d02 100644 (file)
@@ -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
index f6131536662a3c2c4ff25123192e09d4af6aefa4..927fe96af6c312a59241d269dd46b0bb7aa84019 100644 (file)
@@ -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)
 {
index 76e728a495b34718c137924e36f44bacc085814d..0ce80c6ab90f1a4b5388567c10bbf0d8be1ce012 100644 (file)
@@ -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
index 92e3b4972a4e358093762b5c83c077d51ebcd2ee..2752c240e4a62bc4d10866bff68773b30bd924a6 100644 (file)
@@ -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)
index 9e030f645f911dbd9d061551c3f5d77626c3a95a..b402b07cdad469bedec01efd892abf24f2518894 100644 (file)
@@ -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)
index 17a9c6dc5ed7de6a96150ebd3a2cce830bff2e87..e3095c73c3935ad21f88958d189dc688fedfdfe0 100644 (file)
@@ -14,7 +14,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 
-#define FB_POOL(f) ((struct fbpool *)(f)->is_fastbuf)
+#define FB_POOL(f) ((struct fbpool *)(f))
 
 static void
 fbpool_spout(struct fastbuf *b)
index 84395f09891c889b1d31eb39bdbbec8d2d78d318..3f44cbcb3a70a8d53e2fbb7272a7f163879f7d25 100644 (file)
@@ -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)