Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom Tromey <tom@tromey.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tom@tromey.com>
Subject: [RFA v2 03/13] Unused variable fixes related to conditional compilation
Date: Sat, 21 Jul 2018 18:47:00 -0000	[thread overview]
Message-ID: <20180721184720.3263-4-tom@tromey.com> (raw)
In-Reply-To: <20180721184720.3263-1-tom@tromey.com>

This patch fixes various unused variable warnings that are related to
conditional compilation.  In these cases, either the variable is now
protected by the same #if as its uses, or the declaration is simply
lowered into the conditionally-compiled block.

gdb/ChangeLog
2018-07-21  Tom Tromey  <tom@tromey.com>

	* windows-nat.c (saved_context): Conditionally define.
	* remote.c (remote_target::remote_btrace_maybe_reopen):
	Conditionally declare "warned".
	* inflow.c (sigquit_ours): Conditionally define.
	(new_tty): Move "tty" declaration inside #if.
	* guile/guile.c (guile_datadir): Conditionally define.
	* charset.c (set_be_le_names): Move some declarations inside #if.
	* btrace.c (parse_xml_btrace): Move "errcode" declaration inside
	#if.
	(parse_xml_btrace_conf): Likewise.
---
 gdb/ChangeLog     | 13 +++++++++++++
 gdb/btrace.c      |  6 ++----
 gdb/charset.c     |  6 +++---
 gdb/guile/guile.c |  2 ++
 gdb/inflow.c      |  6 ++++--
 gdb/remote.c      |  2 ++
 gdb/windows-nat.c |  2 ++
 7 files changed, 28 insertions(+), 9 deletions(-)

diff --git a/gdb/btrace.c b/gdb/btrace.c
index 35dc90e8e67..e25f047ce24 100644
--- a/gdb/btrace.c
+++ b/gdb/btrace.c
@@ -2202,10 +2202,9 @@ static const struct gdb_xml_element btrace_elements[] = {
 void
 parse_xml_btrace (struct btrace_data *btrace, const char *buffer)
 {
-  int errcode;
-
 #if defined (HAVE_LIBEXPAT)
 
+  int errcode;
   btrace_data result;
   result.format = BTRACE_FORMAT_NONE;
 
@@ -2303,10 +2302,9 @@ static const struct gdb_xml_element btrace_conf_elements[] = {
 void
 parse_xml_btrace_conf (struct btrace_config *conf, const char *xml)
 {
-  int errcode;
-
 #if defined (HAVE_LIBEXPAT)
 
+  int errcode;
   errcode = gdb_xml_parse_quick (_("btrace-conf"), "btrace-conf.dtd",
 				 btrace_conf_elements, xml, conf);
   if (errcode != 0)
diff --git a/gdb/charset.c b/gdb/charset.c
index fcb24a48823..8bb2b4d669f 100644
--- a/gdb/charset.c
+++ b/gdb/charset.c
@@ -295,9 +295,6 @@ static struct gdbarch *be_le_arch;
 static void
 set_be_le_names (struct gdbarch *gdbarch)
 {
-  int i, len;
-  const char *target_wide;
-
   if (be_le_arch == gdbarch)
     return;
   be_le_arch = gdbarch;
@@ -307,6 +304,9 @@ set_be_le_names (struct gdbarch *gdbarch)
   target_wide_charset_le_name = "UTF-32LE";
   target_wide_charset_be_name = "UTF-32BE";
 #else
+  int i, len;
+  const char *target_wide;
+
   target_wide_charset_le_name = NULL;
   target_wide_charset_be_name = NULL;
 
diff --git a/gdb/guile/guile.c b/gdb/guile/guile.c
index 6353b35326b..95b36febed0 100644
--- a/gdb/guile/guile.c
+++ b/gdb/guile/guile.c
@@ -46,8 +46,10 @@ int gdbscm_guile_major_version;
 int gdbscm_guile_minor_version;
 int gdbscm_guile_micro_version;
 
+#ifdef HAVE_GUILE
 /* The guile subdirectory within gdb's data-directory.  */
 static const char *guile_datadir;
+#endif
 
 /* Declared constants and enum for guile exception printing.  */
 const char gdbscm_print_excp_none[] = "none";
diff --git a/gdb/inflow.c b/gdb/inflow.c
index a3b5ba8abef..caff6462070 100644
--- a/gdb/inflow.c
+++ b/gdb/inflow.c
@@ -138,7 +138,9 @@ private:
    to SIG_IGN.  */
 
 static sighandler_t sigint_ours;
+#ifdef SIGQUIT
 static sighandler_t sigquit_ours;
+#endif
 
 /* The name of the tty (from the `tty' command) that we're giving to
    the inferior when starting it up.  This is only (and should only
@@ -825,11 +827,11 @@ check_syscall (const char *msg, int result)
 void
 new_tty (void)
 {
-  int tty;
-
   if (inferior_thisrun_terminal == 0)
     return;
 #if !defined(__GO32__) && !defined(_WIN32)
+  int tty;
+
 #ifdef TIOCNOTTY
   /* Disconnect the child process from our controlling terminal.  On some
      systems (SVR4 for example), this may cause a SIGTTOU, so temporarily
diff --git a/gdb/remote.c b/gdb/remote.c
index a81d67e5ede..a61680d242c 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -13717,7 +13717,9 @@ remote_target::remote_btrace_maybe_reopen ()
   struct remote_state *rs = get_remote_state ();
   struct thread_info *tp;
   int btrace_target_pushed = 0;
+#if !defined (HAVE_LIBIPT)
   int warned = 0;
+#endif
 
   scoped_restore_current_thread restore_thread;
 
diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c
index 3f722a14389..e0e422c0f05 100644
--- a/gdb/windows-nat.c
+++ b/gdb/windows-nat.c
@@ -146,8 +146,10 @@ static GetConsoleFontSize_ftype *GetConsoleFontSize;
 
 static int have_saved_context;	/* True if we've saved context from a
 				   cygwin signal.  */
+#ifdef __CYGWIN__
 static CONTEXT saved_context;	/* Containes the saved context from a
 				   cygwin signal.  */
+#endif
 
 /* If we're not using the old Cygwin header file set, define the
    following which never should have been in the generic Win32 API
-- 
2.13.6


  parent reply	other threads:[~2018-07-21 18:47 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-21 18:47 [RFA v2 00/13] Add -Wunused-variable Tom Tromey
2018-07-21 18:47 ` [RFA v2 11/13] Remove unused variables from gdbserver Tom Tromey
2018-07-21 18:47 ` [RFA v2 08/13] Fix ravenscar-thread.c to use arch_ops Tom Tromey
2018-07-21 18:47 ` Tom Tromey [this message]
2018-07-21 18:47 ` [RFA v2 13/13] Add -Wunused-variable to warnings.m4 Tom Tromey
2018-07-21 18:47 ` [RFA v2 05/13] Call some functions in guile/ for effect Tom Tromey
2018-07-21 18:47 ` [RFA v2 07/13] Call value_fetch_lazy when needed in pretty-printers Tom Tromey
2018-07-21 18:47 ` [RFA v2 10/13] Remove unused declaration from value.c Tom Tromey
2018-07-22  2:13   ` Simon Marchi
2018-07-21 18:47 ` [RFA v2 09/13] Pass the correct argument to the observer in reread_symbols Tom Tromey
2018-07-21 18:47 ` [RFA v2 06/13] Remove dead code from m32c-tdep.c Tom Tromey
2018-07-22  2:10   ` Simon Marchi
2018-07-21 18:47 ` [RFA v2 02/13] Remove an unused variable from spu_get_overlay_table Tom Tromey
2018-07-22  2:06   ` Simon Marchi
2018-07-22 18:59     ` Ulrich Weigand
2018-07-21 18:47 ` [RFA v2 12/13] Conditionally define xmltarget_${name} variable in regdat.sh Tom Tromey
2018-07-21 18:47 ` [RFA v2 01/13] Simple unused variable removals Tom Tromey
2018-07-22  2:04   ` Simon Marchi
2018-07-21 18:47 ` [RFA v2 04/13] Use a previously unused variable in bfin-tdep.c Tom Tromey
2018-07-22  2:26 ` [RFA v2 00/13] Add -Wunused-variable Simon Marchi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180721184720.3263-4-tom@tromey.com \
    --to=tom@tromey.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox