This is the mail archive of the libc-hacker@sources.redhat.com mailing list for the glibc project.

Note that libc-hacker is a closed list. You may look at the archives of this list, but subscription and posting are not open.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Get rid of lvalue casts etc.



GCC 3.4 has removed the support for casts as lvalues. :-(

I'm appending a tested patch for glibc that fixes some of the
problems.

Ok to commit?

Andreas

2004-01-22  Andreas Jaeger  <aj@suse.de>

	* iconv/gconv_simple.c (ucs4le_internal_loop): Remove cast used as
	lvalue.
	(internal_ucs4le_loop_single): Likewise.
	(ucs4_internal_loop): Likewise.
	(BODY): Likewise.

	* iconv/gconv_open.c (__gconv_open): Remove conditional expression
	as lvalue.

============================================================
Index: iconv/gconv_simple.c
--- iconv/gconv_simple.c	11 Jun 2003 21:36:37 -0000	1.59
+++ iconv/gconv_simple.c	22 Jan 2004 11:13:41 -0000
@@ -1,5 +1,5 @@
 /* Simple transformations functions.
-   Copyright (C) 1997-2002, 2003 Free Software Foundation, Inc.
+   Copyright (C) 1997-2003, 2004 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
 
@@ -87,10 +87,12 @@ internal_ucs4_loop (struct __gconv_step 
 #if __BYTE_ORDER == __LITTLE_ENDIAN
   /* Sigh, we have to do some real work.  */
   size_t cnt;
-
+  uint32_t *outptr32 = (uint32_t *) outptr;
+  
   for (cnt = 0; cnt < n_convert; ++cnt, inptr += 4)
-    *((uint32_t *) outptr)++ = bswap_32 (*(const uint32_t *) inptr);
-
+    *outptr32++ = bswap_32 (*(const uint32_t *) inptr);
+  outptr = (unsigned char *) outptr32;
+  
   *inptrp = inptr;
   *outptrp = outptr;
 #elif __BYTE_ORDER == __BIG_ENDIAN
@@ -195,7 +197,8 @@ internal_ucs4_loop_single (struct __gcon
   *outptrp += 4;
 #elif __BYTE_ORDER == __BIG_ENDIAN
   /* XXX unaligned */
-  *(*((uint32_t **) outptrp)++) = state->__value.__wch;
+  *(*((uint32_t **) outptrp)) = state->__value.__wch;
+  *outptrp += sizeof (uint32_t *);
 #else
 # error "This endianess is not supported."
 #endif
@@ -268,7 +271,8 @@ ucs4_internal_loop (struct __gconv_step 
 	  return __GCONV_ILLEGAL_INPUT;
 	}
 
-      *((uint32_t *) outptr)++ = inval;
+      *((uint32_t *) outptr) = inval;
+      outptr += sizeof (uint32_t);
     }
 
   *inptrp = inptr;
@@ -558,7 +562,9 @@ internal_ucs4le_loop_single (struct __gc
   *outptrp += 4;
 #else
   /* XXX unaligned */
-  *(*((uint32_t **) outptrp)++) = state->__value.__wch;
+  
+  *(*((uint32_t **) outptrp)) = state->__value.__wch;
+  *outptrp += sizeof (uint32_t);
 #endif
 
   /* Clear the state buffer.  */
@@ -626,7 +632,8 @@ ucs4le_internal_loop (struct __gconv_ste
 	  return __GCONV_ILLEGAL_INPUT;
 	}
 
-      *((uint32_t *) outptr)++ = inval;
+      *((uint32_t *) outptr) = inval;
+      outptr += sizeof (uint32_t);
     }
 
   *inptrp = inptr;
@@ -808,7 +815,8 @@ ucs4le_internal_loop_single (struct __gc
       }									      \
     else								      \
       /* It's an one byte sequence.  */					      \
-      *((uint32_t *) outptr)++ = *inptr++;				      \
+      *((uint32_t *) outptr) = *inptr++;				      \
+      outptr += sizeof (uint32_t);					      \
   }
 #define LOOP_NEED_FLAGS
 #include <iconv/loop.c>
@@ -838,7 +846,8 @@ ucs4le_internal_loop_single (struct __gc
       }									      \
     else								      \
       /* It's an one byte sequence.  */					      \
-      *outptr++ = *((const uint32_t *) inptr)++;			      \
+      *outptr++ = *((const uint32_t *) inptr);				      \
+      inptr += sizeof (uint32_t);					      \
   }
 #define LOOP_NEED_FLAGS
 #include <iconv/loop.c>
@@ -1032,7 +1041,8 @@ ucs4le_internal_loop_single (struct __gc
       }									      \
 									      \
     /* Now adjust the pointers and store the result.  */		      \
-    *((uint32_t *) outptr)++ = ch;					      \
+    *((uint32_t *) outptr) = ch;					      \
+    outptr += sizeof (uint32_t);					      \
   }
 #define LOOP_NEED_FLAGS
 
@@ -1153,7 +1163,8 @@ ucs4le_internal_loop_single (struct __gc
 	STANDARD_FROM_LOOP_ERR_HANDLER (2);				      \
       }									      \
 									      \
-    *((uint32_t *) outptr)++ = u1;					      \
+    *((uint32_t *) outptr) = u1;					      \
+    outptr += sizeof (uint32_t);			      		      \
     inptr += 2;								      \
   }
 #define LOOP_NEED_FLAGS
@@ -1201,7 +1212,8 @@ ucs4le_internal_loop_single (struct __gc
       }									      \
     else								      \
       {									      \
-	*((uint16_t *) outptr)++ = val;					      \
+	*((uint16_t *) outptr) = val;					      \
+        outptr += sizeof (uint16_t);			      		      \
 	inptr += 4;							      \
       }									      \
   }
@@ -1242,7 +1254,8 @@ ucs4le_internal_loop_single (struct __gc
 	continue;							      \
       }									      \
 									      \
-    *((uint32_t *) outptr)++ = u1;					      \
+    *((uint32_t *) outptr) = u1;					      \
+    outptr += sizeof (uint32_t);			      		      \
     inptr += 2;								      \
   }
 #define LOOP_NEED_FLAGS
@@ -1291,7 +1304,8 @@ ucs4le_internal_loop_single (struct __gc
       }									      \
     else								      \
       {									      \
-	*((uint16_t *) outptr)++ = bswap_16 (val);			      \
+	*((uint16_t *) outptr) = bswap_16 (val);			      \
+    	outptr += sizeof (uint16_t);			      		      \
 	inptr += 4;							      \
       }									      \
   }
============================================================
Index: iconv/gconv_open.c
--- iconv/gconv_open.c	29 Nov 2001 04:51:58 -0000	1.32
+++ iconv/gconv_open.c	22 Jan 2004 11:13:41 -0000
@@ -1,5 +1,5 @@
 /* Find matching transformation algorithms and initialize steps.
-   Copyright (C) 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
+   Copyright (C) 1997, 1998, 1999, 2000, 2001, 2004 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
 
@@ -182,8 +182,13 @@ __gconv_open (const char *toset, const c
 	      || __builtin_expect (__gconv_translit_find (runp), 0) == 0)
 	    lastp = runp;
 	  else
-	    /* This means we haven't found the module.  Remove it.  */
-	    (lastp == NULL ? trans : lastp->next) = runp->next;
+	    {
+	      /* This means we haven't found the module.  Remove it.  */
+	      if (lastp == NULL)
+		trans  = runp->next;
+	      else
+		lastp->next  = runp->next;
+	    }
 	}
 
       /* Allocate room for handle.  */
-- 
 Andreas Jaeger, aj@suse.de, http://www.suse.de/~aj
  SuSE Linux AG, Maxfeldstr. 5, 90409 Nürnberg, Germany
   GPG fingerprint = 93A3 365E CE47 B889 DF7F  FED1 389A 563C C272 A126

Attachment: pgp00000.pgp
Description: PGP signature


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]