Skip to content

Commit

Permalink
Use result size.
Browse files Browse the repository at this point in the history
  • Loading branch information
abeltrano committed Apr 2, 2024
1 parent 540caeb commit 362c47a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ ParseHexString(const std::string& hexString, ContainerT& result)
}

std::string_view hexStringView{ hexString };
for (std::size_t i = 0; i < std::size(hexString); i++) {
for (std::size_t i = 0; i < std::size(result); i++) {
const auto byteAsHex = hexStringView.substr(i * 2, 2); // 2 hex chars
const auto byteConversionResult = std::from_chars(std::data(byteAsHex), std::data(byteAsHex) + std::size(byteAsHex), result[i], 16);
if (byteConversionResult.ec != std::errc{}) {
Expand Down
12 changes: 9 additions & 3 deletions src/common/tools/cli/NetRemoteCli.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -118,14 +118,20 @@ NetRemoteCli::AddSubcommandWifiAccessPointsEnumerate(CLI::App* parent)

namespace detail
{
/**
* @brief Thin wrapper to destructure the std::tuple used to parse SAE passwords.
*
* @param saePasswordArgument The tuple containing the SAE password, password ID, and peer MAC address.
* @return Ieee80211RsnaPassword
*/
Ieee80211RsnaPassword
ParseSaePasswordCliArgument(const std::tuple<std::string, std::optional<std::string>, std::optional<std::string>>& saePasswordArgument)
ParseSaePasswordCliArgument(std::tuple<std::string, std::optional<std::string>, std::optional<std::string>>& saePasswordArgument)
{
const auto& [password, passwordId, peerMacAddress] = saePasswordArgument; // NOLINT(cppcoreguidelines-pro-bounds-constant-array-index)

Ieee80211RsnaPassword saePassword{
.Credential = password,
.PasswordId = passwordId,
.Credential = std::move(password),
.PasswordId = std::move(passwordId),
.PeerMacAddress = peerMacAddress.and_then(Ieee80211MacAddressFromString)
};

Expand Down

0 comments on commit 362c47a

Please sign in to comment.