public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Bernd Edlinger <bernd.edlinger@hotmail.de>
To: "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
Subject: [PATCH v2] sim: fix a warning in dv-sockser.c at connected_p()
Date: Tue, 21 May 2024 06:46:36 +0200	[thread overview]
Message-ID: <AS8P193MB1285E272F529974514EE34CAE4EA2@AS8P193MB1285.EURP193.PROD.OUTLOOK.COM> (raw)

In some O/S e.g. windows there is a warning here about the
unused variable flags which triggers a -Werror build failure.

Fix that by making the variable declaration optional.
---
 sim/common/dv-sockser.c | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)

v2: moved the variable declaration inside the #if block

diff --git a/sim/common/dv-sockser.c b/sim/common/dv-sockser.c
index db81233e25b..8f7425658a9 100644
--- a/sim/common/dv-sockser.c
+++ b/sim/common/dv-sockser.c
@@ -218,7 +218,7 @@ sim_install_dv_sockser (SIM_DESC sd)
 static int
 connected_p (SIM_DESC sd)
 {
-  int numfds,flags;
+  int numfds;
   struct timeval tv;
   fd_set readfds;
   struct sockaddr sockaddr;
@@ -254,15 +254,17 @@ connected_p (SIM_DESC sd)
 
   /* Set non-blocking i/o.  */
 #if defined(F_GETFL) && defined(O_NONBLOCK)
-  flags = fcntl (sockser_fd, F_GETFL);
-  flags |= O_NONBLOCK;
-  if (fcntl (sockser_fd, F_SETFL, flags) == -1)
-    {
-      sim_io_eprintf (sd, "unable to set nonblocking i/o");
-      close (sockser_fd);
-      sockser_fd = -1;
-      return 0;
-    }
+  {
+    int flags = fcntl (sockser_fd, F_GETFL);
+    flags |= O_NONBLOCK;
+    if (fcntl (sockser_fd, F_SETFL, flags) == -1)
+      {
+	sim_io_eprintf (sd, "unable to set nonblocking i/o");
+	close (sockser_fd);
+	sockser_fd = -1;
+	return 0;
+      }
+  }
 #endif
   return 1;
 }
-- 
2.39.2


             reply	other threads:[~2024-05-21  4:44 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-21  4:46 Bernd Edlinger [this message]
2024-05-21 17:55 ` Tom Tromey

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=AS8P193MB1285E272F529974514EE34CAE4EA2@AS8P193MB1285.EURP193.PROD.OUTLOOK.COM \
    --to=bernd.edlinger@hotmail.de \
    --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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).