Skip to content

Commit 83032a4

Browse files
authored
Problem: Build error on MSVC with C++20 in ip.cpp
Solution: Move initialization of variables before gotos.
1 parent 828d6ea commit 83032a4

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/ip.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -559,6 +559,10 @@ int zmq::make_fdpair (fd_t *r_, fd_t *w_)
559559
#ifdef ZMQ_HAVE_IPC
560560
ipc_address_t address;
561561
std::string dirname, filename;
562+
sockaddr_un lcladdr;
563+
socklen_t lcladdr_len = sizeof lcladdr;
564+
int rc = 0;
565+
int saved_errno = 0;
562566

563567
// Create a listening socket.
564568
const SOCKET listener = open_socket (AF_UNIX, SOCK_STREAM, 0);
@@ -570,7 +574,7 @@ int zmq::make_fdpair (fd_t *r_, fd_t *w_)
570574
create_ipc_wildcard_address (dirname, filename);
571575

572576
// Initialise the address structure.
573-
int rc = address.resolve (filename.c_str ());
577+
rc = address.resolve (filename.c_str ());
574578
if (rc != 0) {
575579
goto error_closelistener;
576580
}
@@ -590,9 +594,6 @@ int zmq::make_fdpair (fd_t *r_, fd_t *w_)
590594
goto error_closelistener;
591595
}
592596

593-
sockaddr_un lcladdr;
594-
socklen_t lcladdr_len = sizeof lcladdr;
595-
596597
rc = getsockname (listener, reinterpret_cast<struct sockaddr *> (&lcladdr),
597598
&lcladdr_len);
598599
wsa_assert (rc != -1);
@@ -621,7 +622,7 @@ int zmq::make_fdpair (fd_t *r_, fd_t *w_)
621622
return 0;
622623

623624
error_closeclient:
624-
int saved_errno = errno;
625+
saved_errno = errno;
625626
rc = closesocket (*w_);
626627
wsa_assert (rc == 0);
627628
errno = saved_errno;

0 commit comments

Comments
 (0)