[v2] sim: fix a warning in dv-sockser.c at connected_p()
Checks
Context |
Check |
Description |
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 |
success
|
Testing passed
|
linaro-tcwg-bot/tcwg_gdb_build--master-arm |
success
|
Testing passed
|
linaro-tcwg-bot/tcwg_gdb_check--master-arm |
success
|
Testing passed
|
linaro-tcwg-bot/tcwg_gdb_check--master-aarch64 |
success
|
Testing passed
|
Commit Message
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
Comments
>>>>> "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
@@ -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;
}