diff mbox

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

Message ID 1441705593-1184-3-git-send-email-ilan.peer@intel.com
State Accepted
Headers show

Commit Message

Peer, Ilan Sept. 8, 2015, 9:46 a.m. UTC
Previously, the calculation allowed for the same frequency to appear
several times in the result.

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

Patch

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;
 		}
 	}