This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[commit] -Wunused warning in procfs.c (mips-irix only)
- From: Joel Brobecker <brobecker at adacore dot com>
- To: gdb-patches at sourceware dot org
- Date: Sat, 9 Jan 2010 08:56:37 +0400
- Subject: [commit] -Wunused warning in procfs.c (mips-irix only)
On mips-irix, the compiler is complaining that we are ignoring the
computed value in statements were we are using the praddset/prdelset
macros. The definition of these macros look very similar to the ones
defined on systems such as sparc-solaris except for one important detail:
On sparc-solaris, the macros has a cast that casts the result to void.
Constract what we have on mips-irix:
(((unsigned)((flag)-1) < 32*sizeof(*(sp))/sizeof(__uint32_t)) \
&& (((__uint32_t*)(sp))[((flag)-1)/32] |= (1L<<(((flag)-1)%32))))
... to what we find on sparc-solaris:
((void)(((unsigned)((flag)-1) < 32*sizeof (*(sp))/sizeof (uint32_t)) ? \
(((uint32_t *)(sp))[((flag)-1)/32] |= (1U<<(((flag)-1)%32))) : 0))
The approach I took was to define two new macros gdb_praddset, and
gdb_prdelset that always cast the result to void, and then used that
instead of using the macros directly. This avoids pointing casts
everywhere.
gdb/ChangeLog:
-Wunused warning in procfs.c (mips-irix only).
* procfs.c (gdb_praddset, gdb_prdelset): New macros. Use them
throughout instead of using praddset and prdelset respectively.
This allows us to compile this routine on mips-irix again.
--
Joel
2010-01-03 Joel Brobecker <brobecker@adacore.com>
-Wunused warning in procfs.c (mips-irix only).
* procfs.c (gdb_praddset, gdb_prdelset): New macros. Use them
throughout instead of using praddset and prdelset respectively.
---
gdb/procfs.c | 23 ++++++++++++++++-------
1 files changed, 16 insertions(+), 7 deletions(-)
diff --git a/gdb/procfs.c b/gdb/procfs.c
index e5df886..5791ee7 100644
--- a/gdb/procfs.c
+++ b/gdb/procfs.c
@@ -270,6 +270,15 @@ typedef pr_siginfo64_t gdb_siginfo_t;
typedef struct siginfo gdb_siginfo_t;
#endif
+/* On mips-irix, praddset and prdelset are defined in such a way that
+ they return a value, which causes GCC to emit a -Wunused error
+ because the returned value is not used. Prevent this warning
+ by casting the return value to void. On sparc-solaris, this issue
+ does not exist because the definition of these macros already include
+ that cast to void. */
+#define gdb_praddset(sp, flag) ((void) praddset (sp, flag))
+#define gdb_prdelset(sp, flag) ((void) prdelset (sp, flag))
+
/* gdb_premptysysset */
#ifdef premptysysset
#define gdb_premptysysset premptysysset
@@ -281,14 +290,14 @@ typedef struct siginfo gdb_siginfo_t;
#ifdef praddsysset
#define gdb_praddsysset praddsysset
#else
-#define gdb_praddsysset praddset
+#define gdb_praddsysset gdb_praddset
#endif
/* prdelsysset */
#ifdef prdelsysset
#define gdb_prdelsysset prdelsysset
#else
-#define gdb_prdelsysset prdelset
+#define gdb_prdelsysset gdb_prdelset
#endif
/* prissyssetmember */
@@ -2219,7 +2228,7 @@ proc_trace_signal (procinfo *pi, int signo)
{
if (proc_get_traced_signals (pi, &temp))
{
- praddset (&temp, signo);
+ gdb_praddset (&temp, signo);
return proc_set_traced_signals (pi, &temp);
}
}
@@ -2253,7 +2262,7 @@ proc_ignore_signal (procinfo *pi, int signo)
{
if (proc_get_traced_signals (pi, &temp))
{
- prdelset (&temp, signo);
+ gdb_prdelset (&temp, signo);
return proc_set_traced_signals (pi, &temp);
}
}
@@ -3491,7 +3500,7 @@ procfs_debug_inferior (procinfo *pi)
#else
/* Register to trace hardware faults in the child. */
prfillset (&traced_faults); /* trace all faults... */
- prdelset (&traced_faults, FLTPAGE); /* except page fault. */
+ gdb_prdelset (&traced_faults, FLTPAGE); /* except page fault. */
#endif
if (!proc_set_traced_faults (pi, &traced_faults))
return __LINE__;
@@ -4642,9 +4651,9 @@ register_gdb_signals (procinfo *pi, gdb_sigset_t *signals)
if (signal_stop_state (target_signal_from_host (signo)) == 0 &&
signal_print_state (target_signal_from_host (signo)) == 0 &&
signal_pass_state (target_signal_from_host (signo)) == 1)
- prdelset (signals, signo);
+ gdb_prdelset (signals, signo);
else
- praddset (signals, signo);
+ gdb_praddset (signals, signo);
return proc_set_traced_signals (pi, signals);
}
--
1.5.4.3