Skip to content

Commit

Permalink
Remove remaining Linux C-style casts & fix const correctness (#3079)
Browse files Browse the repository at this point in the history
* Remove remaining Linux C-style casts & fix const correctness

Many C style casts remain after 181f076 ("clang-tidy: Apply fixes
"google-readability-casting" (#3034)").

The reason they were not updated is typically because they are casting
away const qualifiers. Fix these cases or add a const_cast<> if
appropriate.

* Write ReadN(T*&) in terms of ReadN(const T*&)

* Fix timer epochs

* Remove casts around inet_ntop

* Simplify casts around free

* Simplify IPAddress

* Remove casts around setsockopt

* Remove cast from Spake2p "G"

* Document cast around AES_CCM_decrypt

* Add back const_cast around inet_ntop

* Duplicate argv in TestCHIPArgParser

* Revert "Duplicate argv in TestCHIPArgParser"

This reverts commit ec2c119.

* Restyle

* Revert "Revert "Duplicate argv in TestCHIPArgParser""

This reverts commit 8defda3.

* restyle

* Add missing semicolon

* Fix v4 conversions
  • Loading branch information
mspang authored Oct 7, 2020
1 parent c60b0de commit 679e92c
Show file tree
Hide file tree
Showing 37 changed files with 329 additions and 236 deletions.
8 changes: 4 additions & 4 deletions examples/shell/shell_common/cmd_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ static CHIP_ERROR ConfigGetDeviceCert(bool printHeader)
streamer_printf(sout, "DeviceCert: ");
}
// Determine the length of the device certificate.
error = ConfigurationMgr().GetDeviceCertificate((uint8_t *) nullptr, 0, certLen);
error = ConfigurationMgr().GetDeviceCertificate(nullptr, 0, certLen);
SuccessOrExit(error);

// Fail if no certificate has been configured.
Expand Down Expand Up @@ -213,7 +213,7 @@ static CHIP_ERROR ConfigGetDeviceCaCerts(bool printHeader)
streamer_printf(sout, "DeviceCaCerts: ");
}
// Determine the length of the device certificate.
error = ConfigurationMgr().GetDeviceIntermediateCACerts((uint8_t *) nullptr, 0, certLen);
error = ConfigurationMgr().GetDeviceIntermediateCACerts(nullptr, 0, certLen);
SuccessOrExit(error);

// Fail if no certificate has been configured.
Expand Down Expand Up @@ -266,7 +266,7 @@ static CHIP_ERROR ConfigGetManufacturerDeviceCert(bool printHeader)
streamer_printf(sout, "MfrDeviceCert: ");
}
// Determine the length of the device certificate.
error = ConfigurationMgr().GetManufacturerDeviceCertificate((uint8_t *) nullptr, 0, certLen);
error = ConfigurationMgr().GetManufacturerDeviceCertificate(nullptr, 0, certLen);
SuccessOrExit(error);

// Fail if no certificate has been configured.
Expand Down Expand Up @@ -302,7 +302,7 @@ static CHIP_ERROR ConfigGetManufacturerDeviceCaCerts(bool printHeader)
streamer_printf(sout, "MfgDeviceCaCerts:");
}
// Determine the length of the device certificate.
error = ConfigurationMgr().GetManufacturerDeviceIntermediateCACerts((uint8_t *) nullptr, 0, certLen);
error = ConfigurationMgr().GetManufacturerDeviceIntermediateCACerts(nullptr, 0, certLen);
SuccessOrExit(error);

// Fail if no certificate has been configured.
Expand Down
2 changes: 1 addition & 1 deletion src/ble/BLEEndPoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@ BLE_ERROR BLEEndPoint::Init(BleLayer * bleLayer, BLE_CONNECTION_OBJECT connObj,
//
// Beware this line should we ever use virtuals in this class or its
// super(s). See similar lines in chip::System::Layer end points.
memset((void *) this, 0, sizeof(*this));
memset(this, 0, sizeof(*this));

// If end point plays peripheral role, expect ack for indication sent as last step of BTP handshake.
// If central, periperal's handshake indication 'ack's write sent by central to kick off the BTP handshake.
Expand Down
3 changes: 0 additions & 3 deletions src/ble/BtpEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,6 @@ class BtpEngine
static const uint16_t sMaxFragmentSize;

// Public functions:
BtpEngine() {}
~BtpEngine() {}

BLE_ERROR Init(void * an_app_state, bool expect_first_ack);

inline void SetTxFragmentSize(uint8_t size) { mTxFragmentSize = size; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ bool DeviceController_BlePlatformDelegate::SubscribeCharacteristic(BLE_CONNECTIO

if (subscribeCB && svcId && charId)
{
return subscribeCB(connObj, (void *) svcId->bytes, (void *) charId->bytes, subscribe);
return subscribeCB(connObj, static_cast<const void *>(svcId->bytes), static_cast<const void *>(charId->bytes), subscribe);
}

return false;
Expand All @@ -52,7 +52,7 @@ bool DeviceController_BlePlatformDelegate::UnsubscribeCharacteristic(BLE_CONNECT

if (subscribeCB && svcId && charId)
{
return subscribeCB(connObj, (void *) svcId->bytes, (void *) charId->bytes, !subscribe);
return subscribeCB(connObj, static_cast<const void *>(svcId->bytes), static_cast<const void *>(charId->bytes), !subscribe);
}

return false;
Expand Down Expand Up @@ -94,7 +94,8 @@ bool DeviceController_BlePlatformDelegate::SendWriteRequest(BLE_CONNECTION_OBJEC

if (writeCB && svcId && charId && pBuf)
{
ret = writeCB(connObj, (void *) svcId->bytes, (void *) charId->bytes, (void *) pBuf->Start(), pBuf->DataLength());
ret = writeCB(connObj, static_cast<const void *>(svcId->bytes), static_cast<const void *>(charId->bytes),
static_cast<void *>(pBuf->Start()), pBuf->DataLength());
}

// Release delegate's reference to pBuf. pBuf will be freed when both platform delegate and Chip stack free their references to
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@
#include <ble/BleLayer.h>
#include <ble/BlePlatformDelegate.h>

typedef bool (*WriteBleCharacteristicCBFunct)(void * connObj, void * svcId, void * charId, void * buffer, uint16_t length);
typedef bool (*SubscribeBleCharacteristicCBFunct)(void * connObj, void * svcId, void * charId, bool subscribe);
typedef bool (*WriteBleCharacteristicCBFunct)(void * connObj, const void * svcId, const void * charId, const void * buffer,
uint16_t length);
typedef bool (*SubscribeBleCharacteristicCBFunct)(void * connObj, const void * svcId, const void * charId, bool subscribe);
typedef bool (*CloseBleCBFunct)(void * connObj);

class DeviceController_BlePlatformDelegate : public chip::Ble::BlePlatformDelegate
Expand Down
11 changes: 7 additions & 4 deletions src/crypto/CHIPCryptoPAL.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ class ECPKey
public:
virtual SupportedECPKeyTypes Type() const = 0;
virtual size_t Length() const = 0;
virtual operator uint8_t *() const = 0;
virtual operator const uint8_t *() const = 0;
virtual operator uint8_t *() = 0;

virtual CHIP_ERROR ECDSA_validate_msg_signature(const uint8_t * msg, const size_t msg_length, const Sig & signature) const
{
Expand Down Expand Up @@ -143,7 +144,8 @@ class CapacityBoundBuffer

/** @brief Returns buffer pointer
**/
operator uint8_t *() const { return (uint8_t *) bytes; }
operator uint8_t *() { return bytes; }
operator const uint8_t *() const { return bytes; }

private:
uint8_t bytes[Cap];
Expand All @@ -159,7 +161,8 @@ class P256PublicKey : public ECPKey<P256ECDSASignature>
public:
SupportedECPKeyTypes Type() const override { return SupportedECPKeyTypes::ECP256R1; }
size_t Length() const override { return kP256_PublicKey_Length; }
operator uint8_t *() const override { return (uint8_t *) bytes; }
operator uint8_t *() override { return bytes; }
operator const uint8_t *() const override { return bytes; }

CHIP_ERROR ECDSA_validate_msg_signature(const uint8_t * msg, size_t msg_length,
const P256ECDSASignature & signature) const override;
Expand Down Expand Up @@ -646,7 +649,7 @@ class Spake2p

void * M;
void * N;
void * G;
const void * G;
void * X;
void * Y;
void * L;
Expand Down
31 changes: 17 additions & 14 deletions src/crypto/CHIPCryptoPALOpenSSL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,11 @@ CHIP_ERROR AES_CCM_decrypt(const uint8_t * ciphertext, size_t ciphertext_length,
VerifyOrExit(result == 1, error = CHIP_ERROR_INTERNAL);

// Pass in expected tag
// Removing "const" from |tag| here should hopefully be safe as
// we're writing the tag, not reading.
VerifyOrExit(CanCastTo<int>(tag_length), error = CHIP_ERROR_INVALID_ARGUMENT);
result = EVP_CIPHER_CTX_ctrl(context, EVP_CTRL_CCM_SET_TAG, static_cast<int>(tag_length), (void *) tag);
result = EVP_CIPHER_CTX_ctrl(context, EVP_CTRL_CCM_SET_TAG, static_cast<int>(tag_length),
const_cast<void *>(static_cast<const void *>(tag)));
VerifyOrExit(result == 1, error = CHIP_ERROR_INTERNAL);

// Pass in key + iv
Expand Down Expand Up @@ -902,7 +905,7 @@ CHIP_ERROR P256Keypair::Deserialize(P256SerializedKeypair & input)
const uint8_t * privkey = Uint8::to_const_uchar(input) + mPublicKey.Length();

VerifyOrExit(input.Length() == mPublicKey.Length() + kP256_PrivateKey_Length, error = CHIP_ERROR_INVALID_ARGUMENT);
bbuf.Put((const uint8_t *) input, mPublicKey.Length());
bbuf.Put(input, mPublicKey.Length());
VerifyOrExit(bbuf.Fit(), error = CHIP_ERROR_NO_MEMORY);

nid = _nidForCurve(curve);
Expand Down Expand Up @@ -1062,7 +1065,7 @@ CHIP_ERROR P256Keypair::NewCertificateSigningRequest(uint8_t * out_csr, size_t &
{ \
if (_point_ != nullptr) \
{ \
EC_POINT_clear_free((EC_POINT *) _point_); \
EC_POINT_clear_free(static_cast<EC_POINT *>(_point_)); \
} \
} while (0)

Expand All @@ -1071,7 +1074,7 @@ CHIP_ERROR P256Keypair::NewCertificateSigningRequest(uint8_t * out_csr, size_t &
{ \
if (_bn_ != nullptr) \
{ \
BN_clear_free((BIGNUM *) _bn_); \
BN_clear_free(static_cast<BIGNUM *>(_bn_)); \
} \
} while (0)

Expand Down Expand Up @@ -1102,7 +1105,7 @@ CHIP_ERROR Spake2p_P256_SHA256_HKDF_HMAC::InitInternal()
context->curve = EC_GROUP_new_by_curve_name(NID_X9_62_prime256v1);
VerifyOrExit(context->curve != nullptr, error = CHIP_ERROR_INTERNAL);

G = (void *) EC_GROUP_get0_generator(context->curve);
G = EC_GROUP_get0_generator(context->curve);
VerifyOrExit(G != nullptr, error = CHIP_ERROR_INTERNAL);

context->bn_ctx = BN_CTX_secure_new();
Expand Down Expand Up @@ -1229,7 +1232,7 @@ CHIP_ERROR Spake2p_P256_SHA256_HKDF_HMAC::FEWrite(const void * fe, uint8_t * out
CHIP_ERROR error = CHIP_ERROR_INTERNAL;
int bn_out_len;
VerifyOrExit(CanCastTo<int>(out_len), error = CHIP_ERROR_INTERNAL);
bn_out_len = BN_bn2binpad((BIGNUM *) fe, Uint8::to_uchar(out), static_cast<int>(out_len));
bn_out_len = BN_bn2binpad(static_cast<const BIGNUM *>(fe), Uint8::to_uchar(out), static_cast<int>(out_len));

VerifyOrExit(bn_out_len == static_cast<int>(out_len), error = CHIP_ERROR_INTERNAL);

Expand Down Expand Up @@ -1258,8 +1261,8 @@ CHIP_ERROR Spake2p_P256_SHA256_HKDF_HMAC::FEMul(void * fer, const void * fe1, co

Spake2p_Context * context = to_inner_spake2p_context(&mSpake2pContext);

error_openssl =
BN_mod_mul(static_cast<BIGNUM *>(fer), (BIGNUM *) fe1, (BIGNUM *) fe2, static_cast<BIGNUM *>(order), context->bn_ctx);
error_openssl = BN_mod_mul(static_cast<BIGNUM *>(fer), static_cast<const BIGNUM *>(fe1), static_cast<const BIGNUM *>(fe2),
static_cast<BIGNUM *>(order), context->bn_ctx);
VerifyOrExit(error_openssl == 1, error = CHIP_ERROR_INTERNAL);

error = CHIP_NO_ERROR;
Expand Down Expand Up @@ -1288,8 +1291,8 @@ CHIP_ERROR Spake2p_P256_SHA256_HKDF_HMAC::PointWrite(const void * R, uint8_t * o
CHIP_ERROR error = CHIP_ERROR_INTERNAL;
Spake2p_Context * context = to_inner_spake2p_context(&mSpake2pContext);

size_t ec_out_len = EC_POINT_point2oct(context->curve, (EC_POINT *) R, POINT_CONVERSION_UNCOMPRESSED, Uint8::to_uchar(out),
out_len, context->bn_ctx);
size_t ec_out_len = EC_POINT_point2oct(context->curve, static_cast<const EC_POINT *>(R), POINT_CONVERSION_UNCOMPRESSED,
Uint8::to_uchar(out), out_len, context->bn_ctx);
VerifyOrExit(ec_out_len == out_len, error = CHIP_ERROR_INTERNAL);

error = CHIP_NO_ERROR;
Expand All @@ -1304,8 +1307,8 @@ CHIP_ERROR Spake2p_P256_SHA256_HKDF_HMAC::PointMul(void * R, const void * P1, co

Spake2p_Context * context = to_inner_spake2p_context(&mSpake2pContext);

error_openssl =
EC_POINT_mul(context->curve, static_cast<EC_POINT *>(R), nullptr, (EC_POINT *) P1, (BIGNUM *) fe1, context->bn_ctx);
error_openssl = EC_POINT_mul(context->curve, static_cast<EC_POINT *>(R), nullptr, static_cast<const EC_POINT *>(P1),
static_cast<const BIGNUM *>(fe1), context->bn_ctx);
VerifyOrExit(error_openssl == 1, error = CHIP_ERROR_INTERNAL);

error = CHIP_NO_ERROR;
Expand All @@ -1331,8 +1334,8 @@ CHIP_ERROR Spake2p_P256_SHA256_HKDF_HMAC::PointAddMul(void * R, const void * P1,
error = PointMul(R, P2, fe2);
VerifyOrExit(error == CHIP_NO_ERROR, error = CHIP_ERROR_INTERNAL);

error_openssl = EC_POINT_add(context->curve, static_cast<EC_POINT *>(R), static_cast<EC_POINT *>(R), (const EC_POINT *) scratch,
context->bn_ctx);
error_openssl = EC_POINT_add(context->curve, static_cast<EC_POINT *>(R), static_cast<EC_POINT *>(R),
static_cast<const EC_POINT *>(scratch), context->bn_ctx);
VerifyOrExit(error_openssl == 1, error = CHIP_ERROR_INTERNAL);

error = CHIP_NO_ERROR;
Expand Down
6 changes: 3 additions & 3 deletions src/include/platform/internal/BLEManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class BLEManager
CHIP_ERROR SetDeviceName(const char * deviceName);
uint16_t NumConnections();
void OnPlatformEvent(const ChipDeviceEvent * event);
chip::Ble::BleLayer * GetBleLayer() const;
chip::Ble::BleLayer * GetBleLayer();

protected:
// Construction/destruction limited to subclasses.
Expand Down Expand Up @@ -171,9 +171,9 @@ inline void BLEManager::OnPlatformEvent(const ChipDeviceEvent * event)
return static_cast<ImplClass *>(this)->_OnPlatformEvent(event);
}

inline chip::Ble::BleLayer * BLEManager::GetBleLayer() const
inline chip::Ble::BleLayer * BLEManager::GetBleLayer()
{
return static_cast<const ImplClass *>(this)->_GetBleLayer();
return static_cast<ImplClass *>(this)->_GetBleLayer();
}

} // namespace Internal
Expand Down
10 changes: 8 additions & 2 deletions src/inet/IPAddress-StringFuncts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,18 @@ char * IPAddress::ToString(char * buf, uint32_t bufSize) const
#if INET_CONFIG_ENABLE_IPV4
if (IsIPv4())
{
buf = const_cast<char *>(inet_ntop(AF_INET, (const void *) &Addr[3], buf, static_cast<socklen_t>(bufSize)));
const void * addr = &Addr[3];
const char * s = inet_ntop(AF_INET, addr, buf, static_cast<socklen_t>(bufSize));
// This cast is safe because |s| points into |buf| which is not const.
buf = const_cast<char *>(s);
}
else
#endif // INET_CONFIG_ENABLE_IPV4
{
buf = const_cast<char *>(inet_ntop(AF_INET6, (const void *) Addr, buf, static_cast<socklen_t>(bufSize)));
const void * addr = &Addr[0];
const char * s = inet_ntop(AF_INET6, addr, buf, static_cast<socklen_t>(bufSize));
// This cast is safe because |s| points into |buf| which is not const.
buf = const_cast<char *>(s);
}
#endif // !CHIP_SYSTEM_CONFIG_USE_LWIP

Expand Down
35 changes: 17 additions & 18 deletions src/inet/IPAddress.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,9 @@ lwip_ip_addr_type IPAddress::ToLwIPAddrType(IPAddressType typ)
#if INET_CONFIG_ENABLE_IPV4
ip4_addr_t IPAddress::ToIPv4() const
{
return *(ip4_addr_t *) &Addr[3];
ip4_addr_t ipAddr;
memcpy(&ipAddr, &Addr[3], sizeof(ipAddr));
return ipAddr;
}

IPAddress IPAddress::FromIPv4(const ip4_addr_t & ipv4Addr)
Expand All @@ -165,16 +167,17 @@ IPAddress IPAddress::FromIPv4(const ip4_addr_t & ipv4Addr)

ip6_addr_t IPAddress::ToIPv6() const
{
return *(ip6_addr_t *) Addr;
ip6_addr_t ipAddr;
static_assert(sizeof(ipAddr) == sizeof(Addr), "ip6_addr_t size mismatch");
memcpy(&ipAddr, Addr, sizeof(ipAddr));
return ipAddr;
}

IPAddress IPAddress::FromIPv6(const ip6_addr_t & ipv6Addr)
{
IPAddress ipAddr;
ipAddr.Addr[0] = ipv6Addr.addr[0];
ipAddr.Addr[1] = ipv6Addr.addr[1];
ipAddr.Addr[2] = ipv6Addr.addr[2];
ipAddr.Addr[3] = ipv6Addr.addr[3];
static_assert(sizeof(ipAddr) == sizeof(Addr), "ip6_addr_t size mismatch");
memcpy(ipAddr.Addr, &ipv6Addr, sizeof(ipv6Addr));
return ipAddr;
}

Expand Down Expand Up @@ -203,32 +206,28 @@ IPAddress IPAddress::FromIPv4(const struct in_addr & ipv4Addr)

struct in6_addr IPAddress::ToIPv6() const
{
return *(struct in6_addr *) &Addr;
in6_addr ipAddr;
static_assert(sizeof(ipAddr) == sizeof(Addr), "in6_addr size mismatch");
memcpy(&ipAddr, Addr, sizeof(ipAddr));
return ipAddr;
}

IPAddress IPAddress::FromIPv6(const struct in6_addr & ipv6Addr)
{
IPAddress ipAddr;
ipAddr.Addr[0] = htonl((static_cast<uint32_t>(ipv6Addr.s6_addr[0])) << 24 | (static_cast<uint32_t>(ipv6Addr.s6_addr[1])) << 16 |
(static_cast<uint32_t>(ipv6Addr.s6_addr[2])) << 8 | (static_cast<uint32_t>(ipv6Addr.s6_addr[3])));
ipAddr.Addr[1] = htonl((static_cast<uint32_t>(ipv6Addr.s6_addr[4])) << 24 | (static_cast<uint32_t>(ipv6Addr.s6_addr[5])) << 16 |
(static_cast<uint32_t>(ipv6Addr.s6_addr[6])) << 8 | (static_cast<uint32_t>(ipv6Addr.s6_addr[7])));
ipAddr.Addr[2] = htonl((static_cast<uint32_t>(ipv6Addr.s6_addr[8])) << 24 | (static_cast<uint32_t>(ipv6Addr.s6_addr[9])) << 16 |
(static_cast<uint32_t>(ipv6Addr.s6_addr[10])) << 8 | (static_cast<uint32_t>(ipv6Addr.s6_addr[11])));
ipAddr.Addr[3] =
htonl((static_cast<uint32_t>(ipv6Addr.s6_addr[12])) << 24 | (static_cast<uint32_t>(ipv6Addr.s6_addr[13])) << 16 |
(static_cast<uint32_t>(ipv6Addr.s6_addr[14])) << 8 | (static_cast<uint32_t>(ipv6Addr.s6_addr[15])));
static_assert(sizeof(ipAddr) == sizeof(ipv6Addr), "in6_addr size mismatch");
memcpy(ipAddr.Addr, &ipv6Addr, sizeof(ipv6Addr));
return ipAddr;
}

IPAddress IPAddress::FromSockAddr(const struct sockaddr & sockaddr)
{
#if INET_CONFIG_ENABLE_IPV4
if (sockaddr.sa_family == AF_INET)
return FromIPv4(((sockaddr_in *) &sockaddr)->sin_addr);
return FromIPv4(reinterpret_cast<const sockaddr_in *>(&sockaddr)->sin_addr);
#endif // INET_CONFIG_ENABLE_IPV4
if (sockaddr.sa_family == AF_INET6)
return FromIPv6(((sockaddr_in6 *) &sockaddr)->sin6_addr);
return FromIPv6(reinterpret_cast<const sockaddr_in6 *>(&sockaddr)->sin6_addr);
return Any;
}

Expand Down
10 changes: 5 additions & 5 deletions src/inet/IPEndPointBasis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -969,11 +969,11 @@ INET_ERROR IPEndPointBasis::GetSocket(IPAddressType aAddressType, int aType, int
// logic up to check for implementations of these options and
// to provide appropriate HAVE_xxxxx definitions accordingly.

res = setsockopt(mSocket, SOL_SOCKET, SO_REUSEADDR, (void *) &one, sizeof(one));
res = setsockopt(mSocket, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one));
static_cast<void>(res);

#ifdef SO_REUSEPORT
res = setsockopt(mSocket, SOL_SOCKET, SO_REUSEPORT, (void *) &one, sizeof(one));
res = setsockopt(mSocket, SOL_SOCKET, SO_REUSEPORT, &one, sizeof(one));
if (res != 0)
{
ChipLogError(Inet, "SO_REUSEPORT failed: %d", errno);
Expand All @@ -987,7 +987,7 @@ INET_ERROR IPEndPointBasis::GetSocket(IPAddressType aAddressType, int aType, int
#ifdef IPV6_V6ONLY
if (aAddressType == kIPAddressType_IPv6)
{
res = setsockopt(mSocket, IPPROTO_IPV6, IPV6_V6ONLY, (void *) &one, sizeof(one));
res = setsockopt(mSocket, IPPROTO_IPV6, IPV6_V6ONLY, &one, sizeof(one));
if (res != 0)
{
ChipLogError(Inet, "IPV6_V6ONLY failed: %d", errno);
Expand All @@ -999,7 +999,7 @@ INET_ERROR IPEndPointBasis::GetSocket(IPAddressType aAddressType, int aType, int
#ifdef IP_PKTINFO
if (aAddressType == kIPAddressType_IPv4)
{
res = setsockopt(mSocket, IPPROTO_IP, IP_PKTINFO, (void *) &one, sizeof(one));
res = setsockopt(mSocket, IPPROTO_IP, IP_PKTINFO, &one, sizeof(one));
if (res != 0)
{
ChipLogError(Inet, "IP_PKTINFO failed: %d", errno);
Expand All @@ -1011,7 +1011,7 @@ INET_ERROR IPEndPointBasis::GetSocket(IPAddressType aAddressType, int aType, int
#ifdef IPV6_RECVPKTINFO
if (aAddressType == kIPAddressType_IPv6)
{
res = setsockopt(mSocket, IPPROTO_IPV6, IPV6_RECVPKTINFO, (void *) &one, sizeof(one));
res = setsockopt(mSocket, IPPROTO_IPV6, IPV6_RECVPKTINFO, &one, sizeof(one));
if (res != 0)
{
ChipLogError(Inet, "IPV6_PKTINFO failed: %d", errno);
Expand Down
Loading

0 comments on commit 679e92c

Please sign in to comment.