Skip to contentSkip to conversation

net: move random_port() to dns

PATCH New Baruch Siach 2 participants 2 messages May 20, 2020 – Jun 12, 2020 Networking

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: move random_port() to dns

The random_port() routine is not used anywhere else. Make it local to dns.c to reduce code clutter, and shrink generated code a little.

---
 include/net.h |  3 ---
 net/dns.c     | 10 ++++++++++
 net/net.c     | 14 --------------
 3 files changed, 10 insertions(+), 17 deletions(-)
include/net.h +0 -3
index 82500eeb30f7..a5030b395fb6 100644
@@ -890,9 +890,6 @@ int is_serverip_in_cmd(void);
  */
 int net_parse_bootfile(struct in_addr *ipaddr, char *filename, int max_len);
 
-/* get a random source port */
-unsigned int random_port(void);
-
 /**
  * update_tftp - Update firmware over TFTP (via DFU)
  *
net/dns.c +10 -0
index 67d761d7c0f5..dfcd0b85c875 100644
@@ -35,6 +35,16 @@ char *net_dns_env_var;	/* The envvar to store the answer in */
 
 static int dns_our_port;
 
+/*
+ * make port a little random (1024-17407)
+ * This keeps the math somewhat trivial to compute, and seems to work with
+ * all supported protocols/clients/servers
+ */
+static unsigned int random_port(void)
+{
+	return 1024 + (get_timer(0) % 0x4000);
+}
+
 static void dns_send(void)
 {
 	struct header *header;
net/net.c +0 -14
index a76e16b41654..0a42db0a19fb 100644
@@ -1539,20 +1539,6 @@ int net_parse_bootfile(struct in_addr *ipaddr, char *filename, int max_len)
 	return 1;
 }
 
-#if	defined(CONFIG_CMD_NFS)		|| \
-	defined(CONFIG_CMD_SNTP)	|| \
-	defined(CONFIG_CMD_DNS)
-/*
- * make port a little random (1024-17407)
- * This keeps the math somewhat trivial to compute, and seems to work with
- * all supported protocols/clients/servers
- */
-unsigned int random_port(void)
-{
-	return 1024 + (get_timer(0) % 0x4000);
-}
-#endif
-
 void ip_to_string(struct in_addr x, char *s)
 {
 	x.s_addr = ntohl(x.s_addr);
Signature · 1 line
2.26.2
#1 lore raw

PATCH 1/1 net: move random_port() to dns

Quoted 4 lines · Baruch Siach

The random_port() routine is not used anywhere else. Make it local to dns.c to reduce code clutter, and shrink generated code a little.

Applied to u-boot/next, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200612/6162b838/attachment.sig>