@@ -76,7 +76,7 @@ HandleNl80211GetWiphyResponse(struct nl_msg *nl80211Message, void *context) noex
76
76
77
77
/* static */
78
78
std::optional<Nl80211Wiphy>
79
- Nl80211Wiphy::FromId (std::function<void (Microsoft::Net::Netlink::NetlinkMessage &)> addWiphyIdentifier)
79
+ Nl80211Wiphy::FromId (const std::function<void (Microsoft::Net::Netlink::NetlinkMessage &)> & addWiphyIdentifier)
80
80
{
81
81
// Allocate a new netlink socket.
82
82
auto nl80211SocketOpt{ CreateNl80211Socket () };
@@ -178,7 +178,7 @@ Nl80211Wiphy::Parse(struct nl_msg *nl80211Message) noexcept
178
178
std::array<struct nlattr *, NL80211_ATTR_MAX + 1 > wiphyAttributes{};
179
179
int ret = nla_parse (std::data (wiphyAttributes), std::size (wiphyAttributes), genlmsg_attrdata (genl80211MessageHeader, 0 ), genlmsg_attrlen (genl80211MessageHeader, 0 ), nullptr );
180
180
if (ret < 0 ) {
181
- LOGE << std::format (" Failed to parse netlink message attributes with error {} ({})" , ret, strerror (-ret));
181
+ LOGE << std::format (" Failed to parse netlink message attributes with error {} ({})" , ret, strerror (-ret)); // NOLINT(concurrency-mt-unsafe)
182
182
return std::nullopt;
183
183
}
184
184
@@ -189,14 +189,14 @@ Nl80211Wiphy::Parse(struct nl_msg *nl80211Message) noexcept
189
189
}
190
190
191
191
auto wiphyIndex = static_cast <uint32_t >(nla_get_u32 (wiphyAttributes[NL80211_ATTR_WIPHY]));
192
- auto wiphyName = static_cast <const char *>(nla_data (wiphyAttributes[NL80211_ATTR_WIPHY_NAME]));
192
+ const auto * wiphyName = static_cast <const char *>(nla_data (wiphyAttributes[NL80211_ATTR_WIPHY_NAME]));
193
193
194
194
// Process bands.
195
- auto wiphyBands = wiphyAttributes[NL80211_ATTR_WIPHY_BANDS];
195
+ auto * wiphyBands = wiphyAttributes[NL80211_ATTR_WIPHY_BANDS];
196
196
std::unordered_map<nl80211_band, Nl80211WiphyBand> wiphyBandMap{};
197
197
if (wiphyBands != nullptr ) {
198
- int remainingBands;
199
- struct nlattr *wiphyBand;
198
+ int remainingBands = 0 ;
199
+ struct nlattr *wiphyBand = nullptr ;
200
200
201
201
nla_for_each_nested (wiphyBand, wiphyBands, remainingBands)
202
202
{
@@ -214,13 +214,13 @@ Nl80211Wiphy::Parse(struct nl_msg *nl80211Message) noexcept
214
214
215
215
// Process AKM suites.
216
216
// Note: NL80211_ATTR_AKM_SUITES describes the AKMs supported by the PHY (wiphy) and is not specific to an interface.
217
- uint32_t *wiphyAkmSuites;
217
+ uint32_t *wiphyAkmSuites = nullptr ;
218
218
std::size_t wiphyNumAkmSuites = 0 ;
219
219
std::vector<uint32_t > akmSuites{};
220
220
if (wiphyAttributes[NL80211_ATTR_AKM_SUITES] != nullptr ) {
221
221
wiphyAkmSuites = static_cast <uint32_t *>(nla_data (wiphyAttributes[NL80211_ATTR_AKM_SUITES]));
222
222
wiphyNumAkmSuites = static_cast <std::size_t >(nla_len (wiphyAttributes[NL80211_ATTR_AKM_SUITES])) / sizeof (*wiphyAkmSuites);
223
- akmSuites = std::vector<uint32_t >(wiphyAkmSuites, wiphyAkmSuites + wiphyNumAkmSuites);
223
+ akmSuites = std::vector<uint32_t >(wiphyAkmSuites, wiphyAkmSuites + wiphyNumAkmSuites); // NOLINT(cppcoreguidelines-pro-bounds-pointer-arithmetic)
224
224
} else {
225
225
// Per nl80211 documentation, if this attribute is not present, userspace should assume all AKMs are supported.
226
226
akmSuites = Microsoft::Net::Wifi::AllIeee80211Akms;
@@ -230,17 +230,17 @@ Nl80211Wiphy::Parse(struct nl_msg *nl80211Message) noexcept
230
230
std::size_t wiphyNumCipherSuites = 0 ;
231
231
std::vector<uint32_t > cipherSuites{};
232
232
if (wiphyAttributes[NL80211_ATTR_CIPHER_SUITES] != nullptr ) {
233
- uint32_t *wiphyCipherSuites;
233
+ uint32_t *wiphyCipherSuites = nullptr ;
234
234
wiphyNumCipherSuites = static_cast <std::size_t >(nla_len (wiphyAttributes[NL80211_ATTR_CIPHER_SUITES])) / sizeof (*wiphyCipherSuites);
235
235
wiphyCipherSuites = static_cast <uint32_t *>(nla_data (wiphyAttributes[NL80211_ATTR_CIPHER_SUITES]));
236
- cipherSuites = std::vector<uint32_t >(wiphyCipherSuites, wiphyCipherSuites + wiphyNumCipherSuites);
236
+ cipherSuites = std::vector<uint32_t >(wiphyCipherSuites, wiphyCipherSuites + wiphyNumCipherSuites); // NOLINT(cppcoreguidelines-pro-bounds-pointer-arithmetic)
237
237
}
238
238
239
239
// Process supported interface types.
240
240
std::vector<nl80211_iftype> supportedInterfaceTypes{};
241
241
if (wiphyAttributes[NL80211_ATTR_SUPPORTED_IFTYPES] != nullptr ) {
242
- int remainingSupportedInterfaceTypes;
243
- struct nlattr *supportedInterfaceType;
242
+ int remainingSupportedInterfaceTypes = 0 ;
243
+ struct nlattr *supportedInterfaceType = nullptr ;
244
244
nla_for_each_nested (supportedInterfaceType, wiphyAttributes[NL80211_ATTR_SUPPORTED_IFTYPES], remainingSupportedInterfaceTypes)
245
245
{
246
246
auto interfaceType = static_cast <nl80211_iftype>(supportedInterfaceType->nla_type );
0 commit comments