Browse Source

fixup gcc warnings

Remove following warning from common code:
warning: ISO C90 forbids mixed declarations and code
Waldemar Brodkorb 7 years ago
parent
commit
11cf4e8074

+ 4 - 2
include/cancel.h

@@ -60,10 +60,12 @@
 # define CANCELLABLE_SYSCALL(res_type, name, param_list, params)	\
 res_type weak_function name param_list					\
 {									\
+	int oldtype;							\
+	res_type result;						\
 	if (SINGLE_THREAD_P)						\
 		return __NC(name) params;				\
-	int oldtype = LIBC_CANCEL_ASYNC();				\
-	res_type result = __NC(name) params;				\
+	oldtype = LIBC_CANCEL_ASYNC();					\
+	result = __NC(name) params;					\
 	LIBC_CANCEL_RESET(oldtype);					\
 	return result;							\
 }

+ 4 - 1
libc/sysdeps/linux/common/__rt_sigtimedwait.c

@@ -25,6 +25,9 @@
 int __NC(sigtimedwait)(const sigset_t *set, siginfo_t *info,
 		       const struct timespec *timeout)
 {
+# if defined SI_TKILL && defined SI_USER
+	int result;
+# endif
 # ifdef SIGCANCEL
 	sigset_t tmpset;
 
@@ -50,7 +53,7 @@ int __NC(sigtimedwait)(const sigset_t *set, siginfo_t *info,
 	/* XXX The size argument hopefully will have to be changed to the
 	   real size of the user-level sigset_t.  */
 	/* on uClibc we use the kernel sigset_t size */
-	int result = INLINE_SYSCALL(rt_sigtimedwait, 4, set, info,
+	result = INLINE_SYSCALL(rt_sigtimedwait, 4, set, info,
 				    timeout, __SYSCALL_SIGSET_T_SIZE);
 
 	/* The kernel generates a SI_TKILL code in si_code in case tkill is

+ 6 - 3
libc/sysdeps/linux/common/__syscall_fcntl.c

@@ -39,6 +39,9 @@ int fcntl(int fd, int cmd, ...)
 {
 	va_list ap;
 	long arg;
+#ifdef __NEW_THREADS
+	int oldtype, result;
+#endif
 
 	va_start (ap, cmd);
 	arg = va_arg (ap, long);
@@ -51,11 +54,11 @@ int fcntl(int fd, int cmd, ...)
 		return INLINE_SYSCALL(fcntl64, 3, fd, cmd, arg);
 #endif
 #ifdef __NEW_THREADS
-	int oldtype = LIBC_CANCEL_ASYNC ();
+	oldtype = LIBC_CANCEL_ASYNC ();
 #if defined __NR_fcntl
-	int result = __NC(fcntl)(fd, cmd, arg);
+	result = __NC(fcntl)(fd, cmd, arg);
 #else
-	int result = INLINE_SYSCALL(fcntl64, 3, fd, cmd, arg);
+	result = INLINE_SYSCALL(fcntl64, 3, fd, cmd, arg);
 #endif
 	LIBC_CANCEL_RESET (oldtype);
 	return result;

+ 5 - 2
libc/sysdeps/linux/common/__syscall_fcntl64.c

@@ -23,6 +23,9 @@ int fcntl64(int fd, int cmd, ...)
 {
 	long arg;
 	va_list list;
+# ifdef __NEW_THREADS
+	int oldtype, result;
+# endif
 
 	va_start(list, cmd);
 	arg = va_arg(list, long);
@@ -31,8 +34,8 @@ int fcntl64(int fd, int cmd, ...)
 	if (SINGLE_THREAD_P || (cmd != F_SETLKW64))
 		return __NC(fcntl64)(fd, cmd, arg);
 # ifdef __NEW_THREADS
-	int oldtype = LIBC_CANCEL_ASYNC();
-	int result = __NC(fcntl64)(fd, cmd, arg);
+	oldtype = LIBC_CANCEL_ASYNC();
+	result = __NC(fcntl64)(fd, cmd, arg);
 	LIBC_CANCEL_RESET(oldtype);
 	return result;
 # endif

+ 4 - 2
libc/sysdeps/linux/common/bits/syscalls-common.h

@@ -42,10 +42,11 @@
 # define INLINE_SYSCALL_NCS(num, nr, args...)				\
 (__extension__								\
  ({									\
+	long __res;							\
 	INTERNAL_SYSCALL_DECL(__err);					\
 	(__extension__							\
 	 ({								\
-	   long __res = INTERNAL_SYSCALL_NCS(num, __err, nr, args);	\
+	   __res = INTERNAL_SYSCALL_NCS(num, __err, nr, args);		\
 	   if (unlikely(INTERNAL_SYSCALL_ERROR_P(__res, __err))) {	\
 		__set_errno(INTERNAL_SYSCALL_ERRNO(__res, __err));	\
 		__res = -1L;						\
@@ -59,8 +60,9 @@
 #ifndef INLINE_SYSCALL_NOERR_NCS
 # define INLINE_SYSCALL_NOERR_NCS(num, nr, args...)			\
 ({									\
+	long __res;							\
 	INTERNAL_SYSCALL_DECL(__err);					\
-	long __res = INTERNAL_SYSCALL_NCS(num, __err, nr, args);	\
+	__res = INTERNAL_SYSCALL_NCS(num, __err, nr, args);		\
 	__res;								\
 })
 #endif

+ 5 - 2
libc/sysdeps/linux/common/ioctl.c

@@ -20,6 +20,9 @@ int ioctl(int fd, unsigned long int request, ...)
 {
 	void *arg;
 	va_list list;
+#ifdef __NEW_THREADS
+	int oldtype, result;
+#endif
 
 	va_start(list, request);
 	arg = va_arg(list, void *);
@@ -28,8 +31,8 @@ int ioctl(int fd, unsigned long int request, ...)
 	if (SINGLE_THREAD_P)
 		return __syscall_ioctl(fd, request, arg);
 #ifdef __NEW_THREADS
-	int oldtype = LIBC_CANCEL_ASYNC ();
-	int result = __syscall_ioctl(fd, request, arg);
+	oldtype = LIBC_CANCEL_ASYNC ();
+	result = __syscall_ioctl(fd, request, arg);
 	LIBC_CANCEL_RESET (oldtype);
 	return result;
 #endif

+ 6 - 3
libc/sysdeps/linux/common/open.c

@@ -28,6 +28,9 @@ int __open_nocancel(const char *, int, mode_t) __nonnull ((1)) attribute_hidden;
 int open(const char *file, int oflag, ...)
 {
 	mode_t mode = 0;
+#ifdef __NEW_THREADS
+	int oldtype, result;
+#endif
 
 	if (oflag & O_CREAT) {
 		va_list arg;
@@ -44,11 +47,11 @@ int open(const char *file, int oflag, ...)
 #endif
 
 #ifdef __NEW_THREADS
-	int oldtype = LIBC_CANCEL_ASYNC ();
+	oldtype = LIBC_CANCEL_ASYNC ();
 # if defined(__NR_open)
-	int result = __NC(open)(file, oflag, mode);
+	result = __NC(open)(file, oflag, mode);
 # else
-	int result = openat(AT_FDCWD, file, oflag, mode);
+	result = openat(AT_FDCWD, file, oflag, mode);
 # endif
 	LIBC_CANCEL_RESET (oldtype);
 	return result;

+ 4 - 3
libc/sysdeps/linux/common/posix_fadvise64.c

@@ -22,22 +22,23 @@
 
 int posix_fadvise64(int fd, off64_t offset, off64_t len, int advice)
 {
+	int ret;
 	INTERNAL_SYSCALL_DECL (err);
 	/* ARM has always been funky. */
 #if defined (__arm__) || \
     (defined(__UCLIBC_SYSCALL_ALIGN_64BIT__) && (defined(__powerpc__) || defined(__xtensa__)))
 	/* arch with 64-bit data in even reg alignment #1: [powerpc/xtensa]
 	 * custom syscall handler (rearranges @advice to avoid register hole punch) */
-	int ret = INTERNAL_SYSCALL (fadvise64_64, err, 6, fd, advice,
+	ret = INTERNAL_SYSCALL (fadvise64_64, err, 6, fd, advice,
 			OFF64_HI_LO (offset), OFF64_HI_LO (len));
 #elif defined(__UCLIBC_SYSCALL_ALIGN_64BIT__)
 	/* arch with 64-bit data in even reg alignment #2: [arcv2/others-in-future]
 	 * stock syscall handler in kernel (reg hole punched) */
-	int ret = INTERNAL_SYSCALL (fadvise64_64, err, 7, fd, 0,
+	ret = INTERNAL_SYSCALL (fadvise64_64, err, 7, fd, 0,
 			OFF64_HI_LO (offset), OFF64_HI_LO (len),
 			advice);
 # else
-	int ret = INTERNAL_SYSCALL (fadvise64_64, err, 6, fd,
+	ret = INTERNAL_SYSCALL (fadvise64_64, err, 6, fd,
 			OFF64_HI_LO (offset), OFF64_HI_LO (len),
 			advice);
 # endif

+ 5 - 4
libc/sysdeps/linux/common/pselect.c

@@ -36,10 +36,6 @@ static int __NC(pselect)(int nfds, fd_set *readfds, fd_set *writefds,
 	 */
 	struct timespec _ts;
 
-	if (timeout != NULL) {
-		_ts = *timeout;
-		timeout = &_ts;
-	}
 	/* Note: the system call expects 7 values but on most architectures
 	   we can only pass in 6 directly.  If there is an architecture with
 	   support for more parameters a new version of this file needs to
@@ -49,6 +45,11 @@ static int __NC(pselect)(int nfds, fd_set *readfds, fd_set *writefds,
 		__kernel_size_t  ss_len;
 	} data;
 
+	if (timeout != NULL) {
+		_ts = *timeout;
+		timeout = &_ts;
+	}
+
 	if (sigmask != NULL) {
 		data.ss = (__kernel_ulong_t) sigmask;
 		data.ss_len = __SYSCALL_SIGSET_T_SIZE;

+ 5 - 4
libc/sysdeps/linux/common/sched_setaffinity.c

@@ -32,12 +32,13 @@ static size_t __kernel_cpumask_size;
 int sched_setaffinity(pid_t pid, size_t cpusetsize, const cpu_set_t *cpuset)
 {
 	size_t cnt;
+	int res;
+	size_t psize = 128;
+	void *p = alloca (psize);
+
 	if (unlikely (__kernel_cpumask_size == 0)) {
-		INTERNAL_SYSCALL_DECL (err);
-		int res;
-		size_t psize = 128;
-		void *p = alloca (psize);
 
+		INTERNAL_SYSCALL_DECL (err);
 		while (res = INTERNAL_SYSCALL (sched_getaffinity, err, 3, getpid (),
 					       psize, p),
 		       INTERNAL_SYSCALL_ERROR_P (res, err)