[U-Boot] [PATCH v3 14/21] net: cosmetic: Rename parameter len to payload_len

Joe Hershberger joe.hershberger at ni.com
Wed May 23 19:58:10 CEST 2012


This name more explicitly claims that it does not include the
header size

Signed-off-by: Joe Hershberger <joe.hershberger at ni.com>
Cc: Joe Hershberger <joe.hershberger at gmail.com>
---
Changes for v2:
   - Split from "Improve variable names and code readability"
Changes for v3:
   - Documented arguments to NetSendUDPPacket()

 include/net.h |   12 ++++++++++--
 net/net.c     |   15 ++++++++-------
 2 files changed, 18 insertions(+), 9 deletions(-)

diff --git a/include/net.h b/include/net.h
index fd19c42..ff66073 100644
--- a/include/net.h
+++ b/include/net.h
@@ -466,9 +466,17 @@ extern void	NetSetTimeout(ulong, thand_f *);/* Set timeout handler */
 /* Transmit "NetTxPacket" */
 extern void NetSendPacket(uchar *, int);
 
-/* Transmit UDP packet, performing ARP request if needed */
+/*
+ * Transmit UDP packet, performing ARP request if needed
+ *
+ * @param ether Raw packet buffer
+ * @param dest IP address to send the datagram to
+ * @param dport Destination UDP port
+ * @param sport Source UDP port
+ * @param payload_len Length of data after the UDP header
+ */
 extern int	NetSendUDPPacket(uchar *ether, IPaddr_t dest, int dport,
-			int sport, int len);
+			int sport, int payload_len);
 
 /* Processes a received packet */
 extern void NetReceive(uchar *, int);
diff --git a/net/net.c b/net/net.c
index 4cdd9cd..b8a267c 100644
--- a/net/net.c
+++ b/net/net.c
@@ -591,8 +591,8 @@ NetSendPacket(uchar *pkt, int len)
 	(void) eth_send(pkt, len);
 }
 
-int
-NetSendUDPPacket(uchar *ether, IPaddr_t dest, int dport, int sport, int len)
+int NetSendUDPPacket(uchar *ether, IPaddr_t dest, int dport, int sport,
+		int payload_len)
 {
 	uchar *pkt;
 
@@ -618,14 +618,14 @@ NetSendUDPPacket(uchar *ether, IPaddr_t dest, int dport, int sport, int len)
 		pkt = NetArpWaitTxPacket;
 		pkt += NetSetEther(pkt, NetArpWaitPacketMAC, PROT_IP);
 
-		NetSetIP(pkt, dest, dport, sport, len);
+		NetSetIP(pkt, dest, dport, sport, payload_len);
 		memcpy(pkt + IP_UDP_HDR_SIZE, (uchar *)NetTxPacket +
 		       (pkt - (uchar *)NetArpWaitTxPacket) +
-		       IP_UDP_HDR_SIZE, len);
+		       IP_UDP_HDR_SIZE, payload_len);
 
 		/* size of the waiting packet */
 		NetArpWaitTxPacketSize = (pkt - NetArpWaitTxPacket) +
-			IP_UDP_HDR_SIZE + len;
+			IP_UDP_HDR_SIZE + payload_len;
 
 		/* and do the ARP request */
 		NetArpWaitTry = 1;
@@ -638,8 +638,9 @@ NetSendUDPPacket(uchar *ether, IPaddr_t dest, int dport, int sport, int len)
 
 	pkt = (uchar *)NetTxPacket;
 	pkt += NetSetEther(pkt, ether, PROT_IP);
-	NetSetIP(pkt, dest, dport, sport, len);
-	eth_send(NetTxPacket, (pkt - NetTxPacket) + IP_UDP_HDR_SIZE + len);
+	NetSetIP(pkt, dest, dport, sport, payload_len);
+	eth_send(NetTxPacket, (pkt - NetTxPacket) + IP_UDP_HDR_SIZE +
+		payload_len);
 
 	return 0;	/* transmitted */
 }
-- 
1.6.0.2



More information about the U-Boot mailing list