public inbox for libc-ports@sourceware.org
 help / color / mirror / Atom feed
* Use parentheses around MIPS syscall macro arguments
@ 2012-11-20  2:46 Joseph S. Myers
  0 siblings, 0 replies; only message in thread
From: Joseph S. Myers @ 2012-11-20  2:46 UTC (permalink / raw)
  To: libc-ports

The MIPS o32 and n64 syscall macros fail to put parentheses around
their arguments that are cast to (long), resulting in various warnings
when what is cast is only part of the argument expression (for
example, the condition of a conditional expression) and the final
initializer has pointer rather than integer type.  I've applied this
patch to fix this.

2012-11-20  Joseph Myers  <joseph@codesourcery.com>

	* sysdeps/unix/sysv/linux/mips/mips32/sysdep.h
	(internal_syscall1): Use parentheses around macro arguments.
	(internal_syscall2): Likewise.
	(internal_syscall3): Likewise.
	(internal_syscall4): Likewise.
	(internal_syscall5): Likewise.
	(internal_syscall6): Likewise.
	(internal_syscall7): Likewise.
	* sysdeps/unix/sysv/linux/mips/mips64/n64/sysdep.h
	(internal_syscall1): Likewise.
	(internal_syscall2): Likewise.
	(internal_syscall3): Likewise.
	(internal_syscall4): Likewise.
	(internal_syscall5): Likewise.
	(internal_syscall6): Likewise.

diff --git a/ports/sysdeps/unix/sysv/linux/mips/mips32/sysdep.h b/ports/sysdeps/unix/sysv/linux/mips/mips32/sysdep.h
index 1d6ab05..2b683a9 100644
--- a/ports/sysdeps/unix/sysv/linux/mips/mips32/sysdep.h
+++ b/ports/sysdeps/unix/sysv/linux/mips/mips32/sysdep.h
@@ -104,7 +104,7 @@
 									\
 	{								\
 	register long __v0 asm("$2") ncs_init;				\
-	register long __a0 asm("$4") = (long) arg1;			\
+	register long __a0 asm("$4") = (long) (arg1);			\
 	register long __a3 asm("$7");					\
 	__asm__ volatile (						\
 	".set\tnoreorder\n\t"						\
@@ -126,8 +126,8 @@
 									\
 	{								\
 	register long __v0 asm("$2") ncs_init;				\
-	register long __a0 asm("$4") = (long) arg1;			\
-	register long __a1 asm("$5") = (long) arg2;			\
+	register long __a0 asm("$4") = (long) (arg1);			\
+	register long __a1 asm("$5") = (long) (arg2);			\
 	register long __a3 asm("$7");					\
 	__asm__ volatile (						\
 	".set\tnoreorder\n\t"						\
@@ -149,9 +149,9 @@
 									\
 	{								\
 	register long __v0 asm("$2") ncs_init;				\
-	register long __a0 asm("$4") = (long) arg1;			\
-	register long __a1 asm("$5") = (long) arg2;			\
-	register long __a2 asm("$6") = (long) arg3;			\
+	register long __a0 asm("$4") = (long) (arg1);			\
+	register long __a1 asm("$5") = (long) (arg2);			\
+	register long __a2 asm("$6") = (long) (arg3);			\
 	register long __a3 asm("$7");					\
 	__asm__ volatile (						\
 	".set\tnoreorder\n\t"						\
@@ -173,10 +173,10 @@
 									\
 	{								\
 	register long __v0 asm("$2") ncs_init;				\
-	register long __a0 asm("$4") = (long) arg1;			\
-	register long __a1 asm("$5") = (long) arg2;			\
-	register long __a2 asm("$6") = (long) arg3;			\
-	register long __a3 asm("$7") = (long) arg4;			\
+	register long __a0 asm("$4") = (long) (arg1);			\
+	register long __a1 asm("$5") = (long) (arg2);			\
+	register long __a2 asm("$6") = (long) (arg3);			\
+	register long __a3 asm("$7") = (long) (arg4);			\
 	__asm__ volatile (						\
 	".set\tnoreorder\n\t"						\
 	cs_init								\
@@ -205,10 +205,10 @@
 	FORCE_FRAME_POINTER;						\
 	{								\
 	register long __v0 asm("$2") ncs_init;				\
-	register long __a0 asm("$4") = (long) arg1;			\
-	register long __a1 asm("$5") = (long) arg2;			\
-	register long __a2 asm("$6") = (long) arg3;			\
-	register long __a3 asm("$7") = (long) arg4;			\
+	register long __a0 asm("$4") = (long) (arg1);			\
+	register long __a1 asm("$5") = (long) (arg2);			\
+	register long __a2 asm("$6") = (long) (arg3);			\
+	register long __a3 asm("$7") = (long) (arg4);			\
 	__asm__ volatile (						\
 	".set\tnoreorder\n\t"						\
 	"subu\t$29, 32\n\t"						\
@@ -219,7 +219,7 @@
 	".set\treorder"						\
 	: "=r" (__v0), "+r" (__a3)					\
 	: input, "r" (__a0), "r" (__a1), "r" (__a2),			\
-	  "r" ((long)arg5)						\
+	  "r" ((long) (arg5))						\
 	: __SYSCALL_CLOBBERS);						\
 	err = __a3;							\
 	_sys_result = __v0;						\
@@ -234,10 +234,10 @@
 	FORCE_FRAME_POINTER;						\
 	{								\
 	register long __v0 asm("$2") ncs_init;				\
-	register long __a0 asm("$4") = (long) arg1;			\
-	register long __a1 asm("$5") = (long) arg2;			\
-	register long __a2 asm("$6") = (long) arg3;			\
-	register long __a3 asm("$7") = (long) arg4;			\
+	register long __a0 asm("$4") = (long) (arg1);			\
+	register long __a1 asm("$5") = (long) (arg2);			\
+	register long __a2 asm("$6") = (long) (arg3);			\
+	register long __a3 asm("$7") = (long) (arg4);			\
 	__asm__ volatile (						\
 	".set\tnoreorder\n\t"						\
 	"subu\t$29, 32\n\t"						\
@@ -249,7 +249,7 @@
 	".set\treorder"						\
 	: "=r" (__v0), "+r" (__a3)					\
 	: input, "r" (__a0), "r" (__a1), "r" (__a2),			\
-	  "r" ((long)arg5), "r" ((long)arg6)				\
+	  "r" ((long) (arg5)), "r" ((long) (arg6))			\
 	: __SYSCALL_CLOBBERS);						\
 	err = __a3;							\
 	_sys_result = __v0;						\
@@ -264,10 +264,10 @@
 	FORCE_FRAME_POINTER;						\
 	{								\
 	register long __v0 asm("$2") ncs_init;				\
-	register long __a0 asm("$4") = (long) arg1;			\
-	register long __a1 asm("$5") = (long) arg2;			\
-	register long __a2 asm("$6") = (long) arg3;			\
-	register long __a3 asm("$7") = (long) arg4;			\
+	register long __a0 asm("$4") = (long) (arg1);			\
+	register long __a1 asm("$5") = (long) (arg2);			\
+	register long __a2 asm("$6") = (long) (arg3);			\
+	register long __a3 asm("$7") = (long) (arg4);			\
 	__asm__ volatile (						\
 	".set\tnoreorder\n\t"						\
 	"subu\t$29, 32\n\t"						\
@@ -280,7 +280,7 @@
 	".set\treorder"						\
 	: "=r" (__v0), "+r" (__a3)					\
 	: input, "r" (__a0), "r" (__a1), "r" (__a2),			\
-	  "r" ((long)arg5), "r" ((long)arg6), "r" ((long)arg7)		\
+	  "r" ((long) (arg5)), "r" ((long) (arg6)), "r" ((long) (arg7))	\
 	: __SYSCALL_CLOBBERS);						\
 	err = __a3;							\
 	_sys_result = __v0;						\
diff --git a/ports/sysdeps/unix/sysv/linux/mips/mips64/n64/sysdep.h b/ports/sysdeps/unix/sysv/linux/mips/mips64/n64/sysdep.h
index 1d0b7b7..02f196a 100644
--- a/ports/sysdeps/unix/sysv/linux/mips/mips64/n64/sysdep.h
+++ b/ports/sysdeps/unix/sysv/linux/mips/mips64/n64/sysdep.h
@@ -104,7 +104,7 @@
 									\
 	{								\
 	register long __v0 asm("$2") ncs_init;				\
-	register long __a0 asm("$4") = (long) arg1; 			\
+	register long __a0 asm("$4") = (long) (arg1); 			\
 	register long __a3 asm("$7"); 					\
 	__asm__ volatile ( 						\
 	".set\tnoreorder\n\t" 						\
@@ -126,8 +126,8 @@
 									\
 	{								\
 	register long __v0 asm("$2") ncs_init;				\
-	register long __a0 asm("$4") = (long) arg1; 			\
-	register long __a1 asm("$5") = (long) arg2; 			\
+	register long __a0 asm("$4") = (long) (arg1); 			\
+	register long __a1 asm("$5") = (long) (arg2); 			\
 	register long __a3 asm("$7"); 					\
 	__asm__ volatile ( 						\
 	".set\tnoreorder\n\t" 						\
@@ -149,9 +149,9 @@
 									\
 	{								\
 	register long __v0 asm("$2") ncs_init;				\
-	register long __a0 asm("$4") = (long) arg1; 			\
-	register long __a1 asm("$5") = (long) arg2; 			\
-	register long __a2 asm("$6") = (long) arg3; 			\
+	register long __a0 asm("$4") = (long) (arg1); 			\
+	register long __a1 asm("$5") = (long) (arg2); 			\
+	register long __a2 asm("$6") = (long) (arg3); 			\
 	register long __a3 asm("$7"); 					\
 	__asm__ volatile ( 						\
 	".set\tnoreorder\n\t" 						\
@@ -173,10 +173,10 @@
 									\
 	{								\
 	register long __v0 asm("$2") ncs_init;				\
-	register long __a0 asm("$4") = (long) arg1; 			\
-	register long __a1 asm("$5") = (long) arg2; 			\
-	register long __a2 asm("$6") = (long) arg3; 			\
-	register long __a3 asm("$7") = (long) arg4; 			\
+	register long __a0 asm("$4") = (long) (arg1); 			\
+	register long __a1 asm("$5") = (long) (arg2); 			\
+	register long __a2 asm("$6") = (long) (arg3); 			\
+	register long __a3 asm("$7") = (long) (arg4); 			\
 	__asm__ volatile ( 						\
 	".set\tnoreorder\n\t" 						\
 	cs_init								\
@@ -197,11 +197,11 @@
 									\
 	{								\
 	register long __v0 asm("$2") ncs_init;				\
-	register long __a0 asm("$4") = (long) arg1; 			\
-	register long __a1 asm("$5") = (long) arg2; 			\
-	register long __a2 asm("$6") = (long) arg3; 			\
-	register long __a3 asm("$7") = (long) arg4; 			\
-	register long __a4 asm("$8") = (long) arg5; 			\
+	register long __a0 asm("$4") = (long) (arg1); 			\
+	register long __a1 asm("$5") = (long) (arg2); 			\
+	register long __a2 asm("$6") = (long) (arg3); 			\
+	register long __a3 asm("$7") = (long) (arg4); 			\
+	register long __a4 asm("$8") = (long) (arg5); 			\
 	__asm__ volatile ( 						\
 	".set\tnoreorder\n\t" 						\
 	cs_init								\
@@ -222,12 +222,12 @@
 									\
 	{								\
 	register long __v0 asm("$2") ncs_init;				\
-	register long __a0 asm("$4") = (long) arg1; 			\
-	register long __a1 asm("$5") = (long) arg2; 			\
-	register long __a2 asm("$6") = (long) arg3; 			\
-	register long __a3 asm("$7") = (long) arg4; 			\
-	register long __a4 asm("$8") = (long) arg5; 			\
-	register long __a5 asm("$9") = (long) arg6; 			\
+	register long __a0 asm("$4") = (long) (arg1); 			\
+	register long __a1 asm("$5") = (long) (arg2); 			\
+	register long __a2 asm("$6") = (long) (arg3); 			\
+	register long __a3 asm("$7") = (long) (arg4); 			\
+	register long __a4 asm("$8") = (long) (arg5); 			\
+	register long __a5 asm("$9") = (long) (arg6); 			\
 	__asm__ volatile ( 						\
 	".set\tnoreorder\n\t" 						\
 	cs_init								\

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2012-11-20  2:46 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-11-20  2:46 Use parentheses around MIPS syscall macro arguments Joseph S. Myers

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).