Skip to contentSkip to conversation

knownnetworks: update known frequencies maximum to 7115

PATCH In review James Prestwood 3 participants 4 messages Mar 3, 2022

lore
Share & tools
lore

James Prestwood

author
#0 lore raw

PATCH 1/1 knownnetworks: update known frequencies maximum to 7115

With the addition of 6GHz '6000' is no longer the maximum frequency that could be in .known_network.freq.

---
 src/knownnetworks.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
src/knownnetworks.c +1 -1
index 87df8b4d..fc024333 100644
@@ -856,7 +856,7 @@ static struct l_queue *known_frequencies_from_string(char *freq_set_str)
 
 		t = strtoul(freq_set_str, &freq_set_str, 10);
 
-		if (unlikely(errno == ERANGE || !t || t > 6000))
+		if (unlikely(errno == ERANGE || !t || t > 7115))
 			goto error;
 
 		known_freq = l_new(struct known_frequency, 1);
Signature · 1 line
2.34.1
#1 lore raw

src/knownnetworks.c static struct l_queue *known_frequencies_from_string(char *freq_set_str) · line 859

Quoted 2 lines · On Thursday, 3 March 2022 18:22:34 CET James Prestwood wrote:
src/knownnetworks.c +1 -1
-               if (unlikely(errno == ERANGE || !t || t > 6000))
+               if (unlikely(errno == ERANGE || !t || t > 7115))

Sorry if this is a dumb comment, but why use a 'magic number' [1] (which meaning can be derived from the git commit comment, but not when just looking at the source)?

1) https://en.wikipedia.org/wiki/Magic_number_(programming)

author
#2 lore raw
Quoted 9 lines · Diederik de Haas
Quoted 2 lines · On Thursday, 3 March 2022 18:22:34 CET James Prestwood wrote:
-               if (unlikely(errno == ERANGE || !t || t > 6000))
+               if (unlikely(errno == ERANGE || !t || t > 7115))

Sorry if this is a dumb comment, but why use a 'magic number' [1] (which
meaning can be derived from the git commit comment, but not when just looking
at the source)?

I'm not sure if we have a style/rule about this but I think generally if the value is only used once, and its clear what it is, a macro may not be required.

*waits for angry mob*

Denis' recommendation solves a few potential issues in addition to just updating, including the hard coded value.

Quoted 2 lines

1) https://en.wikipedia.org/wiki/Magic_number_(programming)

#3 lore raw
In reply to James Prestwood

Hi James,

Quoted 11 lines · James Prestwood

With the addition of 6GHz '6000' is no longer the maximum frequency that could be in .known_network.freq.

---
  src/knownnetworks.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
src/knownnetworks.c +0 -0
index 87df8b4d..fc024333 100644

src/knownnetworks.c static struct l_queue *known_frequencies_from_string(char *freq_set_str) · line 859

Quoted 5 lines
src/knownnetworks.c +1 -1
@@ -856,7 +856,7 @@ static struct l_queue *known_frequencies_from_string(char *freq_set_str)
 
  		t = strtoul(freq_set_str, &freq_set_str, 10);
 
-		if (unlikely(errno == ERANGE || !t || t > 6000))
+		if (unlikely(errno == ERANGE || !t || t > 7115))

Do you want to use band_freq_to_channel here instead? That one checks the valid freqs...

src/knownnetworks.c static struct l_queue *known_frequencies_from_string(char *freq_set_str) · line 862

Quoted 4 lines
src/knownnetworks.c +0 -0
  			goto error;
 
  		known_freq = l_new(struct known_frequency, 1);

Regards,
-Denis