Skip to content

Commit

Permalink
Address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
ksperling-apple committed Feb 8, 2024
1 parent d735920 commit 27e966a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/platform/Linux/ConnectivityManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1159,7 +1159,7 @@ CHIP_ERROR ConnectivityManagerImpl::ConnectWiFiNetworkWithPDCAsync(

static constexpr char kNAIDomain[] = ".pdc.csa-iot.org";
static constexpr auto keyIdHexSize = keyId.size() * 2;
char identityStr[1 + keyIdHexSize + sizeof(kNAIDomain)];
char identityStr[1 + keyIdHexSize + sizeof(kNAIDomain)]; // sizeof(kNAIDomain) includes null terminator

identityStr[0] = '@';
ReturnErrorOnFailure(Encoding::BytesToUppercaseHexBuffer(keyId.data(), keyId.size(), &identityStr[1], keyIdHexSize));
Expand Down
2 changes: 1 addition & 1 deletion src/platform/Linux/NetworkCommissioningDriver.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ class LinuxWiFiDriver final : public WiFiDriver
struct WiFiNetwork
{
bool Empty() const { return ssidLen == 0; }
bool Match(ByteSpan aSsid) const { return !Empty() && ByteSpan(ssid, ssidLen).data_equal(aSsid); }
bool Matches(ByteSpan aSsid) const { return !Empty() && ByteSpan(ssid, ssidLen).data_equal(aSsid); }

uint8_t ssid[DeviceLayer::Internal::kMaxWiFiSSIDLength];
uint8_t ssidLen = 0;
Expand Down
10 changes: 5 additions & 5 deletions src/platform/Linux/NetworkCommissioningWiFiDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ Status LinuxWiFiDriver::AddOrUpdateNetwork(ByteSpan ssid, ByteSpan credentials,
{
outDebugText.reduce_size(0);
outNetworkIndex = 0;
VerifyOrReturnError(mStagingNetwork.Empty() || mStagingNetwork.Match(ssid), Status::kBoundsExceeded);
VerifyOrReturnError(mStagingNetwork.Empty() || mStagingNetwork.Matches(ssid), Status::kBoundsExceeded);

// Do the check before setting the values, so the data is not updated on error.
VerifyOrReturnError(credentials.size() <= sizeof(mStagingNetwork.credentials), Status::kOutOfRange);
Expand All @@ -190,7 +190,7 @@ Status LinuxWiFiDriver::RemoveNetwork(ByteSpan networkId, MutableCharSpan & outD
{
outDebugText.reduce_size(0);
outNetworkIndex = 0;
VerifyOrReturnError(mStagingNetwork.Match(networkId), Status::kNetworkIDNotFound);
VerifyOrReturnError(mStagingNetwork.Matches(networkId), Status::kNetworkIDNotFound);

// Use empty ssid for representing invalid network
mStagingNetwork.ssidLen = 0;
Expand All @@ -200,7 +200,7 @@ Status LinuxWiFiDriver::RemoveNetwork(ByteSpan networkId, MutableCharSpan & outD
Status LinuxWiFiDriver::ReorderNetwork(ByteSpan networkId, uint8_t index, MutableCharSpan & outDebugText)
{
outDebugText.reduce_size(0);
VerifyOrReturnError(mStagingNetwork.Match(networkId), Status::kNetworkIDNotFound);
VerifyOrReturnError(mStagingNetwork.Matches(networkId), Status::kNetworkIDNotFound);
VerifyOrReturnError(index == 0, Status::kOutOfRange);
// We only support one network, so reorder is actually no-op.
return Status::kSuccess;
Expand All @@ -212,7 +212,7 @@ void LinuxWiFiDriver::ConnectNetwork(ByteSpan networkId, ConnectCallback * callb
Status networkingStatus = Status::kSuccess;

const auto & network = mStagingNetwork;
VerifyOrExit(network.Match(networkId), networkingStatus = Status::kNetworkIDNotFound);
VerifyOrExit(network.Matches(networkId), networkingStatus = Status::kNetworkIDNotFound);

#if CHIP_DEVICE_CONFIG_ENABLE_WIFI_PDC
if (network.UsingPDC())
Expand Down Expand Up @@ -291,7 +291,7 @@ CHIP_ERROR LinuxWiFiDriver::AddOrUpdateNetworkWithPDC(ByteSpan ssid, ByteSpan ne
{
CHIP_ERROR err = CHIP_NO_ERROR;
outStatus = Status::kUnknownError;
VerifyOrExit(mStagingNetwork.Empty() || mStagingNetwork.Match(ssid), outStatus = Status::kBoundsExceeded);
VerifyOrExit(mStagingNetwork.Empty() || mStagingNetwork.Matches(ssid), outStatus = Status::kBoundsExceeded);

VerifyOrExit(!ssid.empty() && ssid.size() <= sizeof(WiFiNetwork::ssid), outStatus = Status::kOutOfRange);
VerifyOrExit(!networkIdentity.empty() && networkIdentity.size() <= sizeof(WiFiNetwork::networkIdentity),
Expand Down

0 comments on commit 27e966a

Please sign in to comment.