[PATCH 02/26] P2P: Fix the calculation of group common freqs

Ilan Peer ilan.peer at intel.com
Tue Sep 8 05:46:09 EDT 2015


Previously, the calculation allowed for the same frequency to appear
several times in the result.

Signed-off-by: Ilan Peer <ilan.peer at intel.com>
---
 src/p2p/p2p_utils.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/src/p2p/p2p_utils.c b/src/p2p/p2p_utils.c
index e139d03..0f22bde 100644
--- a/src/p2p/p2p_utils.c
+++ b/src/p2p/p2p_utils.c
@@ -459,13 +459,21 @@ int p2p_channels_to_freqs(const struct p2p_channels *channels, int *freq_list,
 			break;
 		for (j = 0; j < c->channels; j++) {
 			int freq;
+			unsigned int k;
+
 			if (idx + 1 == max_len)
 				break;
 			freq = p2p_channel_to_freq(c->reg_class,
 						   c->channel[j]);
 			if (freq < 0)
 				continue;
-			freq_list[idx++] = freq;
+
+			for (k = 0; k < idx; k++)
+				if (freq_list[k] == freq)
+					break;
+
+			if (k == idx)
+				freq_list[idx++] = freq;
 		}
 	}
 
-- 
1.9.1



More information about the HostAP mailing list