Skip to content

Commit

Permalink
Fix -Wundef issues in src/inet. (#29221)
Browse files Browse the repository at this point in the history
* __MBED__ should be tested for via ifdef.
* HAVE_SO_BINDTODEVICE should be an actual config macro.
  • Loading branch information
bzbarsky-apple committed Sep 14, 2023
1 parent a831ad7 commit 4ff1d3b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
11 changes: 11 additions & 0 deletions src/inet/InetConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -272,4 +272,15 @@
#endif
#endif // INET_CONFIG_UDP_SOCKET_PKTINFO

/**
* @def HAVE_SO_BINDTODEVICE
*
* @brief
* Should be set to 1 if the SO_BINDTODEVICE option to setsockopt is
* available.
*/
#ifndef HAVE_SO_BINDTODEVICE
#define HAVE_SO_BINDTODEVICE 0
#endif

// clang-format on
4 changes: 2 additions & 2 deletions src/inet/InetInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ short InterfaceIterator::GetFlags()
mIntfFlags = intfData.ifr_flags;
mIntfFlagsCached = true;
}
#if __MBED__
#ifdef __MBED__
CloseIOCTLSocket();
#endif
}
Expand Down Expand Up @@ -670,7 +670,7 @@ uint8_t InterfaceAddressIterator::GetPrefixLength()
{
if (mCurAddr->ifa_addr->sa_family == AF_INET6)
{
#if !__MBED__
#ifndef __MBED__
struct sockaddr_in6 & netmask = *reinterpret_cast<struct sockaddr_in6 *>(mCurAddr->ifa_netmask);
return NetmaskToPrefixLength(netmask.sin6_addr.s6_addr, 16);
#else // __MBED__
Expand Down
10 changes: 5 additions & 5 deletions src/inet/TCPEndPointImplSockets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -797,19 +797,19 @@ void TCPEndPointImplSockets::HandlePendingIO(System::SocketEvents events)
// The socket being writable indicates the connection has completed (successfully or otherwise).
if (events.Has(System::SocketEventFlags::kWrite))
{
#if !__MBED__
#ifndef __MBED__
// Get the connection result from the socket.
int osConRes;
socklen_t optLen = sizeof(osConRes);
if (getsockopt(mSocket, SOL_SOCKET, SO_ERROR, &osConRes, &optLen) != 0)
{
osConRes = errno;
}
#else
// On Mbed OS, connect blocks and never returns EINPROGRESS
// The socket option SO_ERROR is not available.
#else // __MBED__
// On Mbed OS, connect blocks and never returns EINPROGRESS
// The socket option SO_ERROR is not available.
int osConRes = 0;
#endif
#endif // !__MBED__
CHIP_ERROR conRes = CHIP_ERROR_POSIX(osConRes);

// Process the connection result.
Expand Down

0 comments on commit 4ff1d3b

Please sign in to comment.