From 09067e777e2ae365744548bd7814f0affecf2088 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Thu, 1 Jul 2021 22:13:45 +0800 Subject: [PATCH] msg/async/net_handler: do not define variable unless it is used on WIN32, `flags` is not used at all, hence GCC complains like ../src/msg/async/net_handler.cc: In member function 'int ceph::NetHandler::set_nonblock(int)': ../src/msg/async/net_handler.cc:67:7: warning: unused variable 'flags' [-Wunused-variable] 67 | int flags; | ^~~~~ this change silences the warning. Signed-off-by: Kefu Chai --- src/msg/async/net_handler.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/msg/async/net_handler.cc b/src/msg/async/net_handler.cc index 59e641511fcd..862c834bc8d7 100644 --- a/src/msg/async/net_handler.cc +++ b/src/msg/async/net_handler.cc @@ -64,10 +64,8 @@ int NetHandler::create_socket(int domain, bool reuse_addr) int NetHandler::set_nonblock(int sd) { - int flags; int r = 0; - - #ifdef _WIN32 +#ifdef _WIN32 ULONG mode = 1; r = ioctlsocket(sd, FIONBIO, &mode); if (r) { @@ -75,7 +73,9 @@ int NetHandler::set_nonblock(int sd) << " " << WSAGetLastError() << dendl; return -r; } - #else +#else + int flags; + /* Set the socket nonblocking. * Note that fcntl(2) for F_GETFL and F_SETFL can't be * interrupted by a signal. */ @@ -89,7 +89,7 @@ int NetHandler::set_nonblock(int sd) lderr(cct) << __func__ << " fcntl(F_SETFL,O_NONBLOCK): " << cpp_strerror(r) << dendl; return -r; } - #endif +#endif return 0; } -- 2.47.3