]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
msg/async/net_handler: do not define variable unless it is used
authorKefu Chai <kchai@redhat.com>
Thu, 1 Jul 2021 14:13:45 +0000 (22:13 +0800)
committerKefu Chai <kchai@redhat.com>
Thu, 1 Jul 2021 14:16:13 +0000 (22:16 +0800)
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 <kchai@redhat.com>
src/msg/async/net_handler.cc

index 59e641511fcdd3ab8c4d26fa950cccdf1e282000..862c834bc8d7965b8b60863939e41ef795333428 100644 (file)
@@ -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;
 }