wiphy: fix wiphy_contrain_freq_set skipping last channel
PATCH 1/2 wiphy: fix wiphy_contrain_freq_set skipping last channel
The loop iterating the frequency attributes list was not including the entire channel set since it was stopping at i < band->freqs_len. The freq_attrs array is allocated to include the last channel:
band->freq_attrs = l_new(struct band_freq_attrs, num_channels + 1); band->freqs_len = num_channels;
So instead the for loop should use i <= band->freqs_len. (I also changed this to start the loop at 1 since channel zero is invalid).
--- src/wiphy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
src/wiphy.c +1 -1
@@ -843,7 +843,7 @@ bool wiphy_constrain_freq_set(const struct wiphy *wiphy,if (!band)continue ; -for (i =0 ; i < band->freqs_len; i++) { +for (i =1 ; i <= band->freqs_len; i++) {uint32_t freq;if (!band->freq_attrs[i].supported)
Signature · 1 line
2.25.1
PATCH 2/2 unit: include frequency 7115 in test-band
The test was not including the last frequency in the 6ghz spectrum.
--- unit/test-band.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
unit/test-band.c +1 -1
@@ -644,7 +644,7 @@ static void test_6ghz_freqs(const void *data)uint32_t i;enum band_freq band; -for (i =5955 ; i <7115 ; i +=20 ) { +for (i =5955 ; i <=7115 ; i +=20 ) {assert (band_freq_to_channel (i, &band) !=0 );assert (band ==BAND_FREQ_6_GHZ ); }
Signature · 1 line
2.25.1
Hi James,
Quoted 4 lines · James Prestwood
The loop iterating the frequency attributes list was not including the entire channel set since it was stopping at i <
band->freqs_len. Thefreq_attrsarray is allocated to include the last channel:
Quoted 8 lines
band->freq_attrs=l_new(struct band_freq_attrs, num_channels + 1);band->freqs_len=num_channels;So instead the for loop should use i <=
band->freqs_len. (I also changed this to start the loop at 1 since channel zero is invalid).--- src/wiphy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Both applied, thanks.
Regards,
-Denis