diff mbox

Fix 'set but not used' warnings in MIPS build

Message ID 320b8da1-1d49-46d6-bd64-e5898f148a39@BAMAIL02.ba.imgtec.org
State Accepted, archived
Headers show

Commit Message

Steve Ellcey Jan. 23, 2014, 11:28 p.m. UTC
While looking at the MIPS uclibc build, I notice there are a lot of warnings
about variables being set but not used.  This has been brought up before:

  http://lists.uclibc.org/pipermail/uclibc/2012-April/046639.html

But it doesn't look like anyone has submitted a patch so here is a patch
I created to get rid of the MIPS specific warnings.  Is this something that
could be checked in?

Also, I was wondering if anyone knows why INTERNAL_SYSCALL_DECL (and other
INTERNAL_SYSCALL_* and internal_syscall* macros) are defined in both
libc/sysdeps/linux/mips/bits/syscalls.h and libc/sysdeps/linux/mips/sysdep.h?

Is one of these the 'right' place to define these macros?  Should one
of them be including the other?

Steve Ellcey
sellcey@mips.com

Comments

Bernhard Reutner-Fischer Jan. 24, 2014, 10:26 p.m. UTC | #1
On Thu, Jan 23, 2014 at 03:28:15PM -0800, Steve Ellcey  wrote:
>While looking at the MIPS uclibc build, I notice there are a lot of warnings
>about variables being set but not used.  This has been brought up before:
>
>  http://lists.uclibc.org/pipermail/uclibc/2012-April/046639.html
>
>But it doesn't look like anyone has submitted a patch so here is a patch
>I created to get rid of the MIPS specific warnings.  Is this something that
>could be checked in?

Yes, but please make sure to follow uclibc.org/developing#contrib
i.e. you have to provide a correct Signed-off-by line.

Also, please use attribute_unused instead.
>
>Also, I was wondering if anyone knows why INTERNAL_SYSCALL_DECL (and other
>INTERNAL_SYSCALL_* and internal_syscall* macros) are defined in both
>libc/sysdeps/linux/mips/bits/syscalls.h and libc/sysdeps/linux/mips/sysdep.h?
>
>Is one of these the 'right' place to define these macros?  Should one
>of them be including the other?

This probably could need cleanup yes, but i did not look closely.
I think that i386 and arm should be okish in this respect.

The mips port could generally need some TLC so it would be great if you
could help.

Please be careful not to break the different THREAD variants, at least
NO_THREAD and NPTL but also not willingly breaking LT.OLD would be nice
until we fade out LT.OLD and LT(.NEW) in favour of NPTL.

thanks,
diff mbox

Patch

diff --git a/libc/sysdeps/linux/mips/bits/atomic.h b/libc/sysdeps/linux/mips/bits/atomic.h
index 9a9f60f..e8d9264 100644
--- a/libc/sysdeps/linux/mips/bits/atomic.h
+++ b/libc/sysdeps/linux/mips/bits/atomic.h
@@ -135,22 +135,22 @@  typedef uintmax_t uatomic_max_t;
 /* For all "bool" routines, we return FALSE if exchange succesful.  */
 
 #define __arch_compare_and_exchange_bool_8_int(mem, new, old, rel, acq)	\
-({ __typeof (*mem) __prev; int __cmp;					\
+({ __typeof (*mem) __prev __attribute__ ((unused)) ; int __cmp;		\
    __arch_compare_and_exchange_xxx_8_int(mem, new, old, rel, acq);	\
    !__cmp; })
 
 #define __arch_compare_and_exchange_bool_16_int(mem, new, old, rel, acq) \
-({ __typeof (*mem) __prev; int __cmp;					\
+({ __typeof (*mem) __prev __attribute__ ((unused)); int __cmp;		\
    __arch_compare_and_exchange_xxx_16_int(mem, new, old, rel, acq);	\
    !__cmp; })
 
 #define __arch_compare_and_exchange_bool_32_int(mem, new, old, rel, acq) \
-({ __typeof (*mem) __prev; int __cmp;					\
+({ __typeof (*mem) __prev __attribute__ ((unused)); int __cmp;		\
    __arch_compare_and_exchange_xxx_32_int(mem, new, old, rel, acq);	\
    !__cmp; })
 
 #define __arch_compare_and_exchange_bool_64_int(mem, new, old, rel, acq) \
-({ __typeof (*mem) __prev; int __cmp;					\
+({ __typeof (*mem) __prev __attribute__ ((unused)); int __cmp;		\
    __arch_compare_and_exchange_xxx_64_int(mem, new, old, rel, acq);	\
    !__cmp; })
 
@@ -158,22 +158,22 @@  typedef uintmax_t uatomic_max_t;
    successful or not.  */
 
 #define __arch_compare_and_exchange_val_8_int(mem, new, old, rel, acq)	\
-({ __typeof (*mem) __prev; int __cmp;					\
+({ __typeof (*mem) __prev __attribute__ ((unused)); int __cmp;		\
    __arch_compare_and_exchange_xxx_8_int(mem, new, old, rel, acq);	\
    (__typeof (*mem))__prev; })
 
 #define __arch_compare_and_exchange_val_16_int(mem, new, old, rel, acq) \
-({ __typeof (*mem) __prev; int __cmp;					\
+({ __typeof (*mem) __prev __attribute__ ((unused)); int __cmp;		\
    __arch_compare_and_exchange_xxx_16_int(mem, new, old, rel, acq);	\
    (__typeof (*mem))__prev; })
 
 #define __arch_compare_and_exchange_val_32_int(mem, new, old, rel, acq) \
-({ __typeof (*mem) __prev; int __cmp;					\
+({ __typeof (*mem) __prev __attribute__ ((unused)); int __cmp;		\
    __arch_compare_and_exchange_xxx_32_int(mem, new, old, rel, acq);	\
    (__typeof (*mem))__prev; })
 
 #define __arch_compare_and_exchange_val_64_int(mem, new, old, rel, acq) \
-({ __typeof (*mem) __prev; int __cmp;					\
+({ __typeof (*mem) __prev __attribute__ ((unused)); int __cmp;		\
    __arch_compare_and_exchange_xxx_64_int(mem, new, old, rel, acq);	\
    (__typeof (*mem))__prev; })
 
diff --git a/libc/sysdeps/linux/mips/bits/syscalls.h b/libc/sysdeps/linux/mips/bits/syscalls.h
index 944d038..53765a9 100644
--- a/libc/sysdeps/linux/mips/bits/syscalls.h
+++ b/libc/sysdeps/linux/mips/bits/syscalls.h
@@ -29,7 +29,7 @@ 
        }								\
      result_var; })
 
-#define INTERNAL_SYSCALL_DECL(err) long err
+#define INTERNAL_SYSCALL_DECL(err) long err __attribute__ ((unused))
 
 #define INTERNAL_SYSCALL_ERROR_P(val, err)   ((long) (err))
 
diff --git a/libc/sysdeps/linux/mips/sysdep.h b/libc/sysdeps/linux/mips/sysdep.h
index 46b6c53..b553333 100644
--- a/libc/sysdeps/linux/mips/sysdep.h
+++ b/libc/sysdeps/linux/mips/sysdep.h
@@ -144,7 +144,7 @@  L(syse1):
      result_var; })
 
 #undef INTERNAL_SYSCALL_DECL
-#define INTERNAL_SYSCALL_DECL(err) long err
+#define INTERNAL_SYSCALL_DECL(err) long err __attribute__ ((unused))
 
 #undef INTERNAL_SYSCALL_ERROR_P
 #define INTERNAL_SYSCALL_ERROR_P(val, err)   ((long) (err))
diff --git a/libpthread/nptl/sysdeps/mips/tls.h b/libpthread/nptl/sysdeps/mips/tls.h
index c522f21..b82bdc9 100644
--- a/libpthread/nptl/sysdeps/mips/tls.h
+++ b/libpthread/nptl/sysdeps/mips/tls.h
@@ -120,7 +120,7 @@  typedef struct
    operation can cause a failure 'errno' must not be touched.  */
 # define TLS_INIT_TP(tcbp, secondcall) \
   ({ INTERNAL_SYSCALL_DECL (err);					\
-     long result_var;							\
+     long result_var  __attribute__((unused));				\
      result_var = INTERNAL_SYSCALL (set_thread_area, err, 1,		\
 				    (char *) (tcbp) + TLS_TCB_OFFSET);	\
      INTERNAL_SYSCALL_ERROR_P (result_var, err)				\