This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


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

fixinc patch for rpc/xdr.h lvalue casts


Here is the corresponding fixincludes patch to the glibc patch
stopping <rpc/xdr.h> from using casts as lvalues.  Bootstrapped with
no regressions on i686-pc-linux-gnu, checked it does fix old installed
<rpc/xdr.h>, and passes fixinc "make check".  OK to commit?

2004-03-25  Joseph S. Myers  <jsm@polyomino.org.uk>

	* fixinc/inclhack.def (rpc_xdr_lvalue_cast_a,
	rpc_xdr_lvalue_cast_b): New fixes.
	* fixinc/tests/base/rpc/xdr.h: Add new tests.

diff -ruN fixinc.orig/inclhack.def fixinc/inclhack.def
--- fixinc.orig/inclhack.def	2004-01-24 00:20:17.000000000 +0000
+++ fixinc/inclhack.def	2004-03-24 21:08:17.000000000 +0000
@@ -2230,6 +2230,31 @@
 
 
 /*
+ *  Fix casts as lvalues in glibc's <rpc/xdr.h>.
+ */
+fix = {
+    hackname  = rpc_xdr_lvalue_cast_a;
+    files     = rpc/xdr.h;
+    select    = "#define[ \t]*IXDR_GET_LONG.*\\\\\n.*__extension__.*";
+    c_fix     = format;
+    c_fix_arg = "#define IXDR_GET_LONG(buf) ((long)IXDR_GET_U_INT32(buf))";
+    test_text = "#define IXDR_GET_LONG(buf) \\\\\n"
+                "\t((long)ntohl((u_long)*__extension__((u_int32_t*)(buf))++))";
+};
+
+
+fix = {
+    hackname  = rpc_xdr_lvalue_cast_b;
+    files     = rpc/xdr.h;
+    select    = "#define[ \t]*IXDR_PUT_LONG.*\\\\\n.*__extension__.*";
+    c_fix     = format;
+    c_fix_arg = "#define IXDR_PUT_LONG(buf, v) ((long)IXDR_PUT_INT32(buf, (long)(v)))";
+    test_text = "#define IXDR_PUT_LONG(buf, v) \\\\\n"
+                "\t(*__extension__((u_int32_t*)(buf))++ = (long)htonl((u_long)(v)))";
+};
+
+
+/*
  *  function class(double x) conflicts with C++ keyword on rs/6000
  */
 fix = {
diff -ruN fixinc.orig/tests/base/rpc/xdr.h fixinc/tests/base/rpc/xdr.h
--- fixinc.orig/tests/base/rpc/xdr.h	2004-03-25 00:49:03.000000000 +0000
+++ fixinc/tests/base/rpc/xdr.h	2004-03-24 21:10:10.000000000 +0000
@@ -9,6 +9,16 @@
 
 
 
+#if defined( RPC_XDR_LVALUE_CAST_A_CHECK )
+#define IXDR_GET_LONG(buf) ((long)IXDR_GET_U_INT32(buf))
+#endif  /* RPC_XDR_LVALUE_CAST_A_CHECK */
+
+
+#if defined( RPC_XDR_LVALUE_CAST_B_CHECK )
+#define IXDR_PUT_LONG(buf, v) ((long)IXDR_PUT_INT32(buf, (long)(v)))
+#endif  /* RPC_XDR_LVALUE_CAST_B_CHECK */
+
+
 #if defined( STRUCT_FILE_CHECK )
 struct __file_s;
 extern void xdrstdio_create( struct __file_s* );

-- 
Joseph S. Myers
jsm@polyomino.org.uk


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