From: Kefu Chai Date: Thu, 1 Jul 2021 14:13:45 +0000 (+0800) Subject: msg/async/net_handler: do not define variable unless it is used X-Git-Tag: v17.1.0~1470^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=09067e777e2ae365744548bd7814f0affecf2088;p=ceph-ci.git 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 --- diff --git a/src/msg/async/net_handler.cc b/src/msg/async/net_handler.cc index 59e641511fc..862c834bc8d 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; }