* [PATCH v2] sim: fix a warning in dv-sockser.c at connected_p()
@ 2024-05-21 4:46 Bernd Edlinger
2024-05-21 17:55 ` Tom Tromey
0 siblings, 1 reply; 2+ messages in thread
From: Bernd Edlinger @ 2024-05-21 4:46 UTC (permalink / raw)
To: gdb-patches
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH v2] sim: fix a warning in dv-sockser.c at connected_p()
2024-05-21 4:46 [PATCH v2] sim: fix a warning in dv-sockser.c at connected_p() Bernd Edlinger
@ 2024-05-21 17:55 ` Tom Tromey
0 siblings, 0 replies; 2+ messages in thread
From: Tom Tromey @ 2024-05-21 17:55 UTC (permalink / raw)
To: Bernd Edlinger; +Cc: gdb-patches
>>>>> "Bernd" == Bernd Edlinger <bernd.edlinger@hotmail.de> writes:
Bernd> + {
Bernd> + int flags = fcntl (sockser_fd, F_GETFL);
You don't need a new block here.
Tom
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-05-21 17:55 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-21 4:46 [PATCH v2] sim: fix a warning in dv-sockser.c at connected_p() Bernd Edlinger
2024-05-21 17:55 ` Tom Tromey
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).