aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorJohannes Berg <johannes.berg@intel.com>2025-05-04 13:26:29 +0300
committerMiri Korenblit <miriam.rachel.korenblit@intel.com>2025-05-07 06:08:01 +0300
commitd6bf0778f7e16148d90397f1b21389a47656d4d4 (patch)
tree9df16d561d6cbd6272556bab4d201855431fdb05
parentwifi: iwlwifi: cfg: use minimum API version 97 for Sc/Dr (diff)
downloadwireguard-linux-d6bf0778f7e16148d90397f1b21389a47656d4d4.tar.xz
wireguard-linux-d6bf0778f7e16148d90397f1b21389a47656d4d4.zip
wifi: iwlwifi: tests: simplify devinfo_no_trans_cfg_dups()
There's no need to build a list of individual configs first and then compare them, we can just go through all of them and compare if the pointers aren't the same. The complexity (in terms of number of comparisons) is a bit higher that way, but it's just a test and the code complexity is much lower without that. Signed-off-by: Johannes Berg <johannes.berg@intel.com> Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com> Link: https://patch.msgid.link/20250504132447.85911c59d96a.I540f464229da3566d1726dfb61b46002fbb73bde@changeid
-rw-r--r--drivers/net/wireless/intel/iwlwifi/tests/devinfo.c42
1 files changed, 10 insertions, 32 deletions
diff --git a/drivers/net/wireless/intel/iwlwifi/tests/devinfo.c b/drivers/net/wireless/intel/iwlwifi/tests/devinfo.c
index bf15e8bdc4e8..d5071fde20cf 100644
--- a/drivers/net/wireless/intel/iwlwifi/tests/devinfo.c
+++ b/drivers/net/wireless/intel/iwlwifi/tests/devinfo.c
@@ -157,43 +157,21 @@ static void devinfo_pci_ids(struct kunit *test)
static void devinfo_no_trans_cfg_dups(struct kunit *test)
{
- /* allocate iwl_dev_info_table_size as upper bound */
- const struct iwl_cfg_trans_params **cfgs;
- int count = 0;
- int p = 0;
-
- for (int i = 0; iwl_hw_card_ids[i].vendor; i++)
- count++;
-
- cfgs = kunit_kcalloc(test, count, sizeof(*cfgs), GFP_KERNEL);
- KUNIT_ASSERT_NOT_NULL(test, cfgs);
-
- /* build a list of unique (by pointer) configs first */
for (int i = 0; iwl_hw_card_ids[i].vendor; i++) {
- struct iwl_cfg_trans_params *cfg;
- bool found = false;
+ const struct iwl_cfg_trans_params *cfg_i =
+ (void *)iwl_hw_card_ids[i].driver_data;
- cfg = (void *)iwl_hw_card_ids[i].driver_data;
+ for (int j = 0; j < i; j++) {
+ const struct iwl_cfg_trans_params *cfg_j =
+ (void *)iwl_hw_card_ids[j].driver_data;
- for (int j = 0; j < p; j++) {
- if (cfgs[j] == cfg) {
- found = true;
- break;
- }
- }
- if (!found) {
- cfgs[p] = cfg;
- p++;
- }
- }
+ if (cfg_i == cfg_j)
+ continue;
- /* check that they're really all different */
- for (int i = 0; i < p; i++) {
- for (int j = 0; j < i; j++) {
- KUNIT_EXPECT_NE_MSG(test, memcmp(cfgs[i], cfgs[j],
- sizeof(*cfgs[i])), 0,
+ KUNIT_EXPECT_NE_MSG(test, memcmp(cfg_j, cfg_i,
+ sizeof(*cfg_i)), 0,
"identical configs: %ps and %ps\n",
- cfgs[i], cfgs[j]);
+ cfg_i, cfg_j);
}
}
}