* [U-Boot] [PATCH 0/8] net/net.c: clenups for checkpatch compliance
@ 2011-05-04 12:40 Luca Ceresoli
2011-05-04 12:40 ` [U-Boot] [PATCH 1/8] net/net.c: cosmetic: fix lines over 80 characters Luca Ceresoli
` (16 more replies)
0 siblings, 17 replies; 32+ messages in thread
From: Luca Ceresoli @ 2011-05-04 12:40 UTC (permalink / raw)
To: u-boot
Hi,
net/net.c currently raises a lot of checkpatch issues: 76 errors, 197 warnings.
This patchset fixes most of them, leaving 0 errors and 25 warnings.
Since the changes are quite massive I split them in separate patches, one
per each category of errors/warning.
The 25 warnings still present are of the following types:
- WARNING: consider using kstrto* in preference to simple_strtoul
which is Linux-specific;
- WARNING: externs should be avoided in .c files
these are due to loop-dependencies between net/net.c and other files;
- WARNING: line over 80 characters
described in the commit message for patch 1;
- WARNING: Use of volatile is usually wrong [...]
I've had a quick look at these, but I don't know in detail how the
networking code and Ethernet drivers (and maybe DMA?) interact, so I cannot
remove them being sure that things will continue working.
Luca Ceresoli (8):
net/net.c: cosmetic: fix lines over 80 characters
net/net.c: cosmetic: variable initializations
net/net.c: cosmetic: fix whitespace issues
net/net.c: cosmetic: fix brace issues
net/net.c: cosmetic: fix pointer syntax issues
net/net.c: cosmetic: parentheses not required for return
net/net.c: cosmetic: fix indentation
net/net.c: cosmetic: do not use assignment in if condition
net/net.c | 600 ++++++++++++++++++++++++++++++++++---------------------------
1 files changed, 333 insertions(+), 267 deletions(-)
^ permalink raw reply [flat|nested] 32+ messages in thread
* [U-Boot] [PATCH 1/8] net/net.c: cosmetic: fix lines over 80 characters
2011-05-04 12:40 [U-Boot] [PATCH 0/8] net/net.c: clenups for checkpatch compliance Luca Ceresoli
@ 2011-05-04 12:40 ` Luca Ceresoli
2011-05-09 19:42 ` Mike Frysinger
2011-05-04 12:40 ` [U-Boot] [PATCH 2/8] net/net.c: cosmetic: variable initializations Luca Ceresoli
` (15 subsequent siblings)
16 siblings, 1 reply; 32+ messages in thread
From: Luca Ceresoli @ 2011-05-04 12:40 UTC (permalink / raw)
To: u-boot
This removes the following checkpatch warning:
- WARNING: line over 80 characters
There is still one such warning that is hard to fix with cosmetic-only
changes without compromising code readability, so I', leaving it as it
is for now:
WARNING: line over 80 characters
#1537: FILE: net.c:1537:
+ [4 tabs] memcpy(((Ethernet_t *)NetArpWaitTxPacket)->et_dest, ...
Signed-off-by: Luca Ceresoli <luca.ceresoli@comelit.it>
Cc: Wolfgang Denk <wd@denx.de>
Cc: Ben Warren <biggerbadderben@gmail.com>
---
net/net.c | 238 +++++++++++++++++++++++++++++++++++++++++--------------------
1 files changed, 159 insertions(+), 79 deletions(-)
diff --git a/net/net.c b/net/net.c
index e50bdf1..90312eb 100644
--- a/net/net.c
+++ b/net/net.c
@@ -101,7 +101,8 @@
DECLARE_GLOBAL_DATA_PTR;
#ifndef CONFIG_ARP_TIMEOUT
-# define ARP_TIMEOUT 5000UL /* Milliseconds before trying ARP again */
+/* Milliseconds before trying ARP again */
+# define ARP_TIMEOUT 5000UL
#else
# define ARP_TIMEOUT CONFIG_ARP_TIMEOUT
#endif
@@ -115,16 +116,24 @@ DECLARE_GLOBAL_DATA_PTR;
/** BOOTP EXTENTIONS **/
-IPaddr_t NetOurSubnetMask=0; /* Our subnet mask (0=unknown) */
-IPaddr_t NetOurGatewayIP=0; /* Our gateways IP address */
-IPaddr_t NetOurDNSIP=0; /* Our DNS IP address */
+/* Our subnet mask (0=unknown) */
+IPaddr_t NetOurSubnetMask=0;
+/* Our gateways IP address */
+IPaddr_t NetOurGatewayIP=0;
+/* Our DNS IP address */
+IPaddr_t NetOurDNSIP=0;
#if defined(CONFIG_BOOTP_DNS2)
-IPaddr_t NetOurDNS2IP=0; /* Our 2nd DNS IP address */
-#endif
-char NetOurNISDomain[32]={0,}; /* Our NIS domain */
-char NetOurHostName[32]={0,}; /* Our hostname */
-char NetOurRootPath[64]={0,}; /* Our bootpath */
-ushort NetBootFileSize=0; /* Our bootfile size in blocks */
+/* Our 2nd DNS IP address */
+IPaddr_t NetOurDNS2IP=0;
+#endif
+/* Our NIS domain */
+char NetOurNISDomain[32]={0,};
+/* Our hostname */
+char NetOurHostName[32]={0,};
+/* Our bootpath */
+char NetOurRootPath[64]={0,};
+/* Our bootfile size in blocks */
+ushort NetBootFileSize=0;
#ifdef CONFIG_MCAST_TFTP /* Multicast TFTP */
IPaddr_t Mcast_addr;
@@ -132,16 +141,25 @@ IPaddr_t Mcast_addr;
/** END OF BOOTP EXTENTIONS **/
-ulong NetBootFileXferSize; /* The actual transferred size of the bootfile (in bytes) */
-uchar NetOurEther[6]; /* Our ethernet address */
-uchar NetServerEther[6] = /* Boot server enet address */
+/* The actual transferred size of the bootfile (in bytes) */
+ulong NetBootFileXferSize;
+/* Our ethernet address */
+uchar NetOurEther[6];
+/* Boot server enet address */
+uchar NetServerEther[6] =
{ 0, 0, 0, 0, 0, 0 };
-IPaddr_t NetOurIP; /* Our IP addr (0 = unknown) */
-IPaddr_t NetServerIP; /* Server IP addr (0 = unknown) */
-volatile uchar *NetRxPacket; /* Current receive packet */
-int NetRxPacketLen; /* Current rx packet length */
-unsigned NetIPID; /* IP packet ID */
-uchar NetBcastAddr[6] = /* Ethernet bcast address */
+/* Our IP addr (0 = unknown) */
+IPaddr_t NetOurIP;
+/* Server IP addr (0 = unknown) */
+IPaddr_t NetServerIP;
+/* Current receive packet */
+volatile uchar *NetRxPacket;
+/* Current rx packet length */
+int NetRxPacketLen;
+/* IP packet ID */
+unsigned NetIPID;
+/* Ethernet bcast address */
+uchar NetBcastAddr[6] =
{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
uchar NetEtherNullAddr[6] =
{ 0, 0, 0, 0, 0, 0 };
@@ -149,24 +167,33 @@ uchar NetEtherNullAddr[6] =
void (*push_packet)(volatile void *, int len) = 0;
#endif
#if defined(CONFIG_CMD_CDP)
-uchar NetCDPAddr[6] = /* Ethernet bcast address */
+/* Ethernet bcast address */
+uchar NetCDPAddr[6] =
{ 0x01, 0x00, 0x0c, 0xcc, 0xcc, 0xcc };
#endif
-int NetState; /* Network loop state */
+/* Network loop state */
+int NetState;
#ifdef CONFIG_NET_MULTI
-int NetRestartWrap = 0; /* Tried all network devices */
-static int NetRestarted = 0; /* Network loop restarted */
-static int NetDevExists = 0; /* At least one device configured */
+/* Tried all network devices */
+int NetRestartWrap = 0;
+/* Network loop restarted */
+static int NetRestarted = 0;
+/* At least one device configured */
+static int NetDevExists = 0;
#endif
/* XXX in both little & big endian machines 0xFFFF == ntohs(-1) */
-ushort NetOurVLAN = 0xFFFF; /* default is without VLAN */
-ushort NetOurNativeVLAN = 0xFFFF; /* ditto */
+/* default is without VLAN */
+ushort NetOurVLAN = 0xFFFF;
+/* ditto */
+ushort NetOurNativeVLAN = 0xFFFF;
-char BootFile[128]; /* Boot File name */
+/* Boot File name */
+char BootFile[128];
#if defined(CONFIG_CMD_PING)
-IPaddr_t NetPingIP; /* the ip address to ping */
+/* the ip address to ping */
+IPaddr_t NetPingIP;
static void PingStart(void);
#endif
@@ -176,8 +203,10 @@ static void CDPStart(void);
#endif
#if defined(CONFIG_CMD_SNTP)
-IPaddr_t NetNtpServerIP; /* NTP server IP address */
-int NetTimeOffset=0; /* offset time from UTC */
+/* NTP server IP address */
+IPaddr_t NetNtpServerIP;
+/* offset time from UTC */
+int NetTimeOffset=0;
#endif
#ifdef CONFIG_NETCONSOLE
@@ -187,13 +216,19 @@ int nc_input_packet(uchar *pkt, unsigned dest, unsigned src, unsigned len);
volatile uchar PktBuf[(PKTBUFSRX+1) * PKTSIZE_ALIGN + PKTALIGN];
-volatile uchar *NetRxPackets[PKTBUFSRX]; /* Receive packets */
+/* Receive packet */
+volatile uchar *NetRxPackets[PKTBUFSRX];
-static rxhand_f *packetHandler; /* Current RX packet handler */
-static thand_f *timeHandler; /* Current timeout handler */
-static ulong timeStart; /* Time base value */
-static ulong timeDelta; /* Current timeout value */
-volatile uchar *NetTxPacket = 0; /* THE transmit packet */
+/* Current RX packet handler */
+static rxhand_f *packetHandler;
+/* Current timeout handler */
+static thand_f *timeHandler;
+/* Time base value */
+static ulong timeStart;
+/* Current timeout value */
+static ulong timeDelta;
+/* THE transmit packet */
+volatile uchar *NetTxPacket = 0;
static int net_check_prereq (proto_t protocol);
@@ -203,8 +238,10 @@ static int NetTryCount;
IPaddr_t NetArpWaitPacketIP;
IPaddr_t NetArpWaitReplyIP;
-uchar *NetArpWaitPacketMAC; /* MAC address of waiting packet's destination */
-uchar *NetArpWaitTxPacket; /* THE transmit packet */
+/* MAC address of waiting packet's destination */
+uchar *NetArpWaitPacketMAC;
+/* THE transmit packet */
+uchar *NetArpWaitTxPacket;
int NetArpWaitTxPacketSize;
uchar NetArpWaitPacketBuf[PKTSIZE_ALIGN + PKTALIGN];
ulong NetArpWaitTimerStart;
@@ -230,10 +267,13 @@ void ArpRequest (void)
arp->ar_pln = 4;
arp->ar_op = htons (ARPOP_REQUEST);
- memcpy (&arp->ar_data[0], NetOurEther, 6); /* source ET addr */
- NetWriteIP ((uchar *) & arp->ar_data[6], NetOurIP); /* source IP addr */
+ /* source ET addr */
+ memcpy (&arp->ar_data[0], NetOurEther, 6);
+ /* source IP addr */
+ NetWriteIP ((uchar *) & arp->ar_data[6], NetOurIP);
for (i = 10; i < 16; ++i) {
- arp->ar_data[i] = 0; /* dest ET addr = 0 */
+ /* dest ET addr = 0 */
+ arp->ar_data[i] = 0;
}
if ((NetArpWaitPacketIP & NetOurSubnetMask) !=
@@ -449,7 +489,9 @@ restart:
}
#if defined(CONFIG_MII) || defined(CONFIG_CMD_MII)
-#if defined(CONFIG_SYS_FAULT_ECHO_LINK_DOWN) && defined(CONFIG_STATUS_LED) && defined(STATUS_LED_RED)
+#if defined(CONFIG_SYS_FAULT_ECHO_LINK_DOWN) && \
+ defined(CONFIG_STATUS_LED) && \
+ defined(STATUS_LED_RED)
/*
* Echo the inverted link state to the fault LED.
*/
@@ -504,7 +546,8 @@ restart:
/*
* Echo the inverted link state to the fault LED.
*/
- if(miiphy_link(eth_get_dev()->name, CONFIG_SYS_FAULT_MII_ADDR)) {
+ if(miiphy_link(eth_get_dev()->name,
+ CONFIG_SYS_FAULT_MII_ADDR)) {
status_led_set (STATUS_LED_RED, STATUS_LED_OFF);
} else {
status_led_set (STATUS_LED_RED, STATUS_LED_ON);
@@ -654,7 +697,10 @@ NetSendUDPPacket(uchar *ether, IPaddr_t dest, int dport, int sport, int len)
if (dest == 0xFFFFFFFF)
ether = NetBcastAddr;
- /* if MAC address was not discovered yet, save the packet and do an ARP request */
+ /*
+ * if MAC address was not discovered yet, save the packet and do
+ * an ARP request
+ */
if (memcmp(ether, NetEtherNullAddr, 6) == 0) {
debug("sending ARP for %08lx\n", dest);
@@ -666,10 +712,12 @@ NetSendUDPPacket(uchar *ether, IPaddr_t dest, int dport, int sport, int len)
pkt += NetSetEther (pkt, NetArpWaitPacketMAC, PROT_IP);
NetSetIP (pkt, dest, dport, sport, len);
- memcpy(pkt + IP_HDR_SIZE, (uchar *)NetTxPacket + (pkt - (uchar *)NetArpWaitTxPacket) + IP_HDR_SIZE, len);
+ memcpy(pkt + IP_HDR_SIZE, (uchar *)NetTxPacket +
+ (pkt - (uchar *)NetArpWaitTxPacket) + IP_HDR_SIZE, len);
/* size of the waiting packet */
- NetArpWaitTxPacketSize = (pkt - NetArpWaitTxPacket) + IP_HDR_SIZE + len;
+ NetArpWaitTxPacketSize = (pkt - NetArpWaitTxPacket) +
+ IP_HDR_SIZE + len;
/* and do the ARP request */
NetArpWaitTry = 1;
@@ -713,9 +761,11 @@ int PingSend(void)
ip = (volatile IP_t *)pkt;
/*
- * Construct an IP and ICMP header. (need to set no fragment bit - XXX)
+ * Construct an IP and ICMP header.
+ * (need to set no fragment bit - XXX)
*/
- ip->ip_hl_v = 0x45; /* IP_HDR_SIZE / 4 (not including UDP) */
+ /* IP_HDR_SIZE / 4 (not including UDP) */
+ ip->ip_hl_v = 0x45;
ip->ip_tos = 0;
ip->ip_len = htons(IP_HDR_SIZE_NO_UDP + 8);
ip->ip_id = htons(NetIPID++);
@@ -723,8 +773,10 @@ int PingSend(void)
ip->ip_ttl = 255;
ip->ip_p = 0x01; /* ICMP */
ip->ip_sum = 0;
- NetCopyIP((void*)&ip->ip_src, &NetOurIP); /* already in network byte order */
- NetCopyIP((void*)&ip->ip_dst, &NetPingIP); /* - "" - */
+ /* already in network byte order */
+ NetCopyIP((void*)&ip->ip_src, &NetOurIP);
+ /* - "" - */
+ NetCopyIP((void*)&ip->ip_dst, &NetPingIP);
ip->ip_sum = ~NetCksum((uchar *)ip, IP_HDR_SIZE_NO_UDP / 2);
s = &ip->udp_src; /* XXX ICMP starts here */
@@ -735,7 +787,8 @@ int PingSend(void)
s[1] = ~NetCksum((uchar *)s, 8/2);
/* size of the waiting packet */
- NetArpWaitTxPacketSize = (pkt - NetArpWaitTxPacket) + IP_HDR_SIZE_NO_UDP + 8;
+ NetArpWaitTxPacketSize =
+ (pkt - NetArpWaitTxPacket) + IP_HDR_SIZE_NO_UDP + 8;
/* and do the ARP request */
NetArpWaitTry = 1;
@@ -800,7 +853,8 @@ static int CDPOK;
ushort CDPNativeVLAN;
ushort CDPApplianceVLAN;
-static const uchar CDP_SNAP_hdr[8] = { 0xAA, 0xAA, 0x03, 0x00, 0x00, 0x0C, 0x20, 0x00 };
+static const uchar CDP_SNAP_hdr[8] = { 0xAA, 0xAA, 0x03, 0x00, 0x00, 0x0C, 0x20,
+ 0x00 };
static ushort CDP_compute_csum(const uchar *buff, ushort len)
{
@@ -831,13 +885,15 @@ static ushort CDP_compute_csum(const uchar *buff, ushort len)
* CDP uses the IP checksum algorithm with a twist;
* for the last byte it *sign* extends and sums.
*/
- result = (result & 0xffff0000) | ((result + leftover) & 0x0000ffff);
+ result = (result & 0xffff0000) |
+ ((result + leftover) & 0x0000ffff);
}
while (result >> 16)
result = (result & 0xFFFF) + (result >> 16);
if (odd)
- result = ((result >> 8) & 0xff) | ((result & 0xff) << 8);
+ result = ((result >> 8) & 0xff) |
+ ((result & 0xff) << 8);
}
/* add up 16-bit and 17-bit words for 17+c bits */
@@ -890,7 +946,8 @@ int CDPSendTrigger(void)
*pkt++ = 180; /* TTL */
s = (volatile ushort *)pkt;
cp = s;
- *s++ = htons(0); /* checksum (0 for later calculation) */
+ /* checksum (0 for later calculation) */
+ *s++ = htons(0);
/* CDP fields */
#ifdef CONFIG_CDP_DEVICE_ID
@@ -962,7 +1019,8 @@ int CDPSendTrigger(void)
et->et_protlen = htons(len);
len = ETHER_HDR_SIZE + sizeof(CDP_SNAP_hdr);
- chksum = CDP_compute_csum((uchar *)NetTxPacket + len, (uchar *)s - (NetTxPacket + len));
+ chksum = CDP_compute_csum((uchar *)NetTxPacket + len,
+ (uchar *)s - (NetTxPacket + len));
if (chksum == 0)
chksum = 0xFFFF;
*cp = htons(chksum);
@@ -1019,10 +1077,13 @@ CDPHandler(const uchar * pkt, unsigned len)
if (pkt[0] < 0x02 || pkt[1] == 0)
return;
- /* if version is greater than 0x02 maybe we'll have a problem; output a warning */
+ /*
+ * if version is greater than 0x02 maybe we'll have a problem;
+ * output a warning
+ */
if (pkt[0] != 0x02)
- printf("** WARNING: CDP packet received with a protocol version %d > 2\n",
- pkt[0] & 0xff);
+ printf("** WARNING: CDP packet received with a protocol version"
+ "%d > 2\n", pkt[0] & 0xff);
if (CDP_compute_csum(pkt, len) != 0)
return;
@@ -1075,10 +1136,12 @@ CDPHandler(const uchar * pkt, unsigned len)
ss = (const ushort *)(t + 1);
#ifdef CONFIG_CDP_APPLIANCE_VLAN_TYPE
- if (applid == CONFIG_CDP_APPLIANCE_VLAN_TYPE)
+ if (applid ==
+ CONFIG_CDP_APPLIANCE_VLAN_TYPE)
vlan = *ss;
#else
- vlan = ntohs(*ss); /* XXX will this work; dunno */
+ /* XXX will this work; dunno */
+ vlan = ntohs(*ss);
#endif
t += 3; tlen -= 3;
}
@@ -1440,7 +1503,8 @@ NetReceive(volatile uchar * inpkt, int len)
}
switch (ntohs(arp->ar_op)) {
- case ARPOP_REQUEST: /* reply with our IP address */
+ case ARPOP_REQUEST:
+ /* reply with our IP address */
debug("Got ARP REQUEST, return our IP\n");
pkt = (uchar *)et;
pkt += NetSetEther(pkt, et->et_src, PROT_ARP);
@@ -1449,7 +1513,8 @@ NetReceive(volatile uchar * inpkt, int len)
NetCopyIP(&arp->ar_data[16], &arp->ar_data[6]);
memcpy (&arp->ar_data[ 0], NetOurEther, 6);
NetCopyIP(&arp->ar_data[ 6], &NetOurIP);
- (void) eth_send((uchar *)et, (pkt - (uchar *)et) + ARP_HDR_SIZE);
+ (void) eth_send((uchar *)et,
+ (pkt - (uchar *)et) + ARP_HDR_SIZE);
return;
case ARPOP_REPLY: /* arp reply */
@@ -1474,14 +1539,16 @@ NetReceive(volatile uchar * inpkt, int len)
if (tmp == NetArpWaitReplyIP) {
debug("Got it\n");
/* save address for later use */
- memcpy(NetArpWaitPacketMAC, &arp->ar_data[0], 6);
+ memcpy(NetArpWaitPacketMAC,
+ &arp->ar_data[0], 6);
#ifdef CONFIG_NETCONSOLE
(*packetHandler)(0,0,0,0);
#endif
/* modify header, and transmit it */
memcpy(((Ethernet_t *)NetArpWaitTxPacket)->et_dest, NetArpWaitPacketMAC, 6);
- (void) eth_send(NetArpWaitTxPacket, NetArpWaitTxPacketSize);
+ (void) eth_send(NetArpWaitTxPacket,
+ NetArpWaitTxPacketSize);
/* no arp request pending now */
NetArpWaitPacketIP = 0;
@@ -1491,7 +1558,8 @@ NetReceive(volatile uchar * inpkt, int len)
}
return;
default:
- debug("Unexpected ARP opcode 0x%x\n", ntohs(arp->ar_op));
+ debug("Unexpected ARP opcode 0x%x\n",
+ ntohs(arp->ar_op));
return;
}
break;
@@ -1588,19 +1656,22 @@ NetReceive(volatile uchar * inpkt, int len)
case ICMP_REDIRECT:
if (icmph->code != ICMP_REDIR_HOST)
return;
- printf (" ICMP Host Redirect to %pI4 ", &icmph->un.gateway);
+ printf (" ICMP Host Redirect to %pI4 ",
+ &icmph->un.gateway);
return;
#if defined(CONFIG_CMD_PING)
case ICMP_ECHO_REPLY:
/*
- * IP header OK. Pass the packet to the current handler.
+ * IP header OK. Pass the packet to the
+ * current handler.
*/
/* XXX point to ip packet */
(*packetHandler)((uchar *)ip, 0, 0, 0);
return;
case ICMP_ECHO_REQUEST:
- debug("Got ICMP ECHO REQUEST, return %d bytes \n",
- ETHER_HDR_SIZE + len);
+ debug("Got ICMP ECHO REQUEST, "
+ "return %d bytes \n",
+ ETHER_HDR_SIZE + len);
memcpy (&et->et_dest[0], &et->et_src[0], 6);
memcpy (&et->et_src[ 0], NetOurEther, 6);
@@ -1609,13 +1680,15 @@ NetReceive(volatile uchar * inpkt, int len)
ip->ip_off = 0;
NetCopyIP((void*)&ip->ip_dst, &ip->ip_src);
NetCopyIP((void*)&ip->ip_src, &NetOurIP);
- ip->ip_sum = ~NetCksum((uchar *)ip, IP_HDR_SIZE_NO_UDP >> 1);
+ ip->ip_sum = ~NetCksum((uchar *)ip,
+ IP_HDR_SIZE_NO_UDP >> 1);
icmph->type = ICMP_ECHO_REPLY;
icmph->checksum = 0;
icmph->checksum = ~NetCksum((uchar *)icmph,
- (len - IP_HDR_SIZE_NO_UDP) >> 1);
- (void) eth_send((uchar *)et, ETHER_HDR_SIZE + len);
+ (len - IP_HDR_SIZE_NO_UDP) >> 1);
+ (void) eth_send((uchar *)et,
+ ETHER_HDR_SIZE + len);
return;
#endif
default:
@@ -1656,7 +1729,8 @@ NetReceive(volatile uchar * inpkt, int len)
xsum += sumdata;
}
while ((xsum >> 16) != 0) {
- xsum = (xsum & 0x0000ffff) + ((xsum >> 16) & 0x0000ffff);
+ xsum = (xsum & 0x0000ffff) +
+ ((xsum >> 16) & 0x0000ffff);
}
if ((xsum != 0x00000000) && (xsum != 0x0000ffff)) {
printf(" UDP wrong checksum %08lx %08x\n",
@@ -1804,7 +1878,8 @@ NetEthHdrSize(void)
if (myvlanid == (ushort)-1)
myvlanid = VLAN_NONE;
- return ((myvlanid & VLAN_IDMASK) == VLAN_NONE) ? ETHER_HDR_SIZE : VLAN_ETHER_HDR_SIZE;
+ return ((myvlanid & VLAN_IDMASK) == VLAN_NONE) ? ETHER_HDR_SIZE :
+ VLAN_ETHER_HDR_SIZE;
}
int
@@ -1849,7 +1924,8 @@ NetSetIP(volatile uchar * xip, IPaddr_t dest, int dport, int sport, int len)
* Construct an IP and UDP header.
* (need to set no fragment bit - XXX)
*/
- ip->ip_hl_v = 0x45; /* IP_HDR_SIZE / 4 (not including UDP) */
+ /* IP_HDR_SIZE / 4 (not including UDP) */
+ ip->ip_hl_v = 0x45;
ip->ip_tos = 0;
ip->ip_len = htons(IP_HDR_SIZE + len);
ip->ip_id = htons(NetIPID++);
@@ -1857,8 +1933,10 @@ NetSetIP(volatile uchar * xip, IPaddr_t dest, int dport, int sport, int len)
ip->ip_ttl = 255;
ip->ip_p = 17; /* UDP */
ip->ip_sum = 0;
- NetCopyIP((void*)&ip->ip_src, &NetOurIP); /* already in network byte order */
- NetCopyIP((void*)&ip->ip_dst, &dest); /* - "" - */
+ /* already in network byte order */
+ NetCopyIP((void*)&ip->ip_src, &NetOurIP);
+ /* - "" - */
+ NetCopyIP((void*)&ip->ip_dst, &dest);
ip->udp_src = htons(sport);
ip->udp_dst = htons(dport);
ip->udp_len = htons(8 + len);
@@ -1879,7 +1957,9 @@ void copy_filename (char *dst, const char *src, int size)
*dst = '\0';
}
-#if defined(CONFIG_CMD_NFS) || defined(CONFIG_CMD_SNTP) || defined(CONFIG_CMD_DNS)
+#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
--
1.7.1
^ permalink raw reply related [flat|nested] 32+ messages in thread
* [U-Boot] [PATCH 2/8] net/net.c: cosmetic: variable initializations
2011-05-04 12:40 [U-Boot] [PATCH 0/8] net/net.c: clenups for checkpatch compliance Luca Ceresoli
2011-05-04 12:40 ` [U-Boot] [PATCH 1/8] net/net.c: cosmetic: fix lines over 80 characters Luca Ceresoli
@ 2011-05-04 12:40 ` Luca Ceresoli
2011-05-04 13:16 ` Mike Frysinger
2011-05-04 12:40 ` [U-Boot] [PATCH 3/8] net/net.c: cosmetic: fix whitespace issues Luca Ceresoli
` (14 subsequent siblings)
16 siblings, 1 reply; 32+ messages in thread
From: Luca Ceresoli @ 2011-05-04 12:40 UTC (permalink / raw)
To: u-boot
This removes the following checkpatch errors:
- ERROR: do not initialise globals to 0 or NULL
- ERROR: spaces required around that '=' (ctx:VxV)
- ERROR: that open brace { should be on the previous line
Signed-off-by: Luca Ceresoli <luca.ceresoli@comelit.it>
Cc: Wolfgang Denk <wd@denx.de>
Cc: Ben Warren <biggerbadderben@gmail.com>
---
net/net.c | 42 ++++++++++++++++++++----------------------
1 files changed, 20 insertions(+), 22 deletions(-)
diff --git a/net/net.c b/net/net.c
index 90312eb..e89e118 100644
--- a/net/net.c
+++ b/net/net.c
@@ -117,23 +117,23 @@ DECLARE_GLOBAL_DATA_PTR;
/** BOOTP EXTENTIONS **/
/* Our subnet mask (0=unknown) */
-IPaddr_t NetOurSubnetMask=0;
+IPaddr_t NetOurSubnetMask;
/* Our gateways IP address */
-IPaddr_t NetOurGatewayIP=0;
+IPaddr_t NetOurGatewayIP;
/* Our DNS IP address */
-IPaddr_t NetOurDNSIP=0;
+IPaddr_t NetOurDNSIP;
#if defined(CONFIG_BOOTP_DNS2)
/* Our 2nd DNS IP address */
-IPaddr_t NetOurDNS2IP=0;
+IPaddr_t NetOurDNS2IP;
#endif
/* Our NIS domain */
-char NetOurNISDomain[32]={0,};
+char NetOurNISDomain[32] = {0,};
/* Our hostname */
-char NetOurHostName[32]={0,};
+char NetOurHostName[32] = {0,};
/* Our bootpath */
-char NetOurRootPath[64]={0,};
+char NetOurRootPath[64] = {0,};
/* Our bootfile size in blocks */
-ushort NetBootFileSize=0;
+ushort NetBootFileSize;
#ifdef CONFIG_MCAST_TFTP /* Multicast TFTP */
IPaddr_t Mcast_addr;
@@ -146,8 +146,7 @@ ulong NetBootFileXferSize;
/* Our ethernet address */
uchar NetOurEther[6];
/* Boot server enet address */
-uchar NetServerEther[6] =
- { 0, 0, 0, 0, 0, 0 };
+uchar NetServerEther[6];
/* Our IP addr (0 = unknown) */
IPaddr_t NetOurIP;
/* Server IP addr (0 = unknown) */
@@ -159,27 +158,26 @@ int NetRxPacketLen;
/* IP packet ID */
unsigned NetIPID;
/* Ethernet bcast address */
-uchar NetBcastAddr[6] =
- { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
-uchar NetEtherNullAddr[6] =
- { 0, 0, 0, 0, 0, 0 };
+uchar NetBcastAddr[6] = {
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
+uchar NetEtherNullAddr[6];
#ifdef CONFIG_API
void (*push_packet)(volatile void *, int len) = 0;
#endif
#if defined(CONFIG_CMD_CDP)
/* Ethernet bcast address */
-uchar NetCDPAddr[6] =
- { 0x01, 0x00, 0x0c, 0xcc, 0xcc, 0xcc };
+uchar NetCDPAddr[6] = {
+ 0x01, 0x00, 0x0c, 0xcc, 0xcc, 0xcc };
#endif
/* Network loop state */
int NetState;
#ifdef CONFIG_NET_MULTI
/* Tried all network devices */
-int NetRestartWrap = 0;
+int NetRestartWrap;
/* Network loop restarted */
-static int NetRestarted = 0;
+static int NetRestarted;
/* At least one device configured */
-static int NetDevExists = 0;
+static int NetDevExists;
#endif
/* XXX in both little & big endian machines 0xFFFF == ntohs(-1) */
@@ -206,7 +204,7 @@ static void CDPStart(void);
/* NTP server IP address */
IPaddr_t NetNtpServerIP;
/* offset time from UTC */
-int NetTimeOffset=0;
+int NetTimeOffset;
#endif
#ifdef CONFIG_NETCONSOLE
@@ -228,7 +226,7 @@ static ulong timeStart;
/* Current timeout value */
static ulong timeDelta;
/* THE transmit packet */
-volatile uchar *NetTxPacket = 0;
+volatile uchar *NetTxPacket;
static int net_check_prereq (proto_t protocol);
@@ -319,7 +317,7 @@ void ArpTimeoutCheck(void)
static void
NetInitLoop(proto_t protocol)
{
- static int env_changed_id = 0;
+ static int env_changed_id;
bd_t *bd = gd->bd;
int env_id = get_env_id ();
--
1.7.1
^ permalink raw reply related [flat|nested] 32+ messages in thread
* [U-Boot] [PATCH 3/8] net/net.c: cosmetic: fix whitespace issues
2011-05-04 12:40 [U-Boot] [PATCH 0/8] net/net.c: clenups for checkpatch compliance Luca Ceresoli
2011-05-04 12:40 ` [U-Boot] [PATCH 1/8] net/net.c: cosmetic: fix lines over 80 characters Luca Ceresoli
2011-05-04 12:40 ` [U-Boot] [PATCH 2/8] net/net.c: cosmetic: variable initializations Luca Ceresoli
@ 2011-05-04 12:40 ` Luca Ceresoli
2011-05-04 12:40 ` [U-Boot] [PATCH 4/8] net/net.c: cosmetic: fix brace issues Luca Ceresoli
` (13 subsequent siblings)
16 siblings, 0 replies; 32+ messages in thread
From: Luca Ceresoli @ 2011-05-04 12:40 UTC (permalink / raw)
To: u-boot
This removes the following checkpatch issues:
- ERROR: space prohibited after that open parenthesis '('
- ERROR: space prohibited before that close parenthesis ')'
- ERROR: space prohibited after that open square bracket '['
- ERROR: space prohibited after that '&' (ctx:WxW)
- ERROR: spaces required around that '=' (ctx:VxW)
- ERROR: space required before the open parenthesis '('
- ERROR: space required after that ',' (ctx:VxV)
- ERROR: need consistent spacing around '+' (ctx:WxV)
- WARNING: unnecessary whitespace before a quoted newline
- WARNING: please, no spaces at the start of a line
- WARNING: space prohibited between function name and open
parenthesis '('
Signed-off-by: Luca Ceresoli <luca.ceresoli@comelit.it>
Cc: Wolfgang Denk <wd@denx.de>
Cc: Ben Warren <biggerbadderben@gmail.com>
---
net/net.c | 192 ++++++++++++++++++++++++++++++------------------------------
1 files changed, 96 insertions(+), 96 deletions(-)
diff --git a/net/net.c b/net/net.c
index e89e118..630aeee 100644
--- a/net/net.c
+++ b/net/net.c
@@ -228,7 +228,7 @@ static ulong timeDelta;
/* THE transmit packet */
volatile uchar *NetTxPacket;
-static int net_check_prereq (proto_t protocol);
+static int net_check_prereq(proto_t protocol);
static int NetTryCount;
@@ -245,7 +245,7 @@ uchar NetArpWaitPacketBuf[PKTSIZE_ALIGN + PKTALIGN];
ulong NetArpWaitTimerStart;
int NetArpWaitTry;
-void ArpRequest (void)
+void ArpRequest(void)
{
int i;
volatile uchar *pkt;
@@ -255,20 +255,20 @@ void ArpRequest (void)
pkt = NetTxPacket;
- pkt += NetSetEther (pkt, NetBcastAddr, PROT_ARP);
+ pkt += NetSetEther(pkt, NetBcastAddr, PROT_ARP);
arp = (ARP_t *) pkt;
- arp->ar_hrd = htons (ARP_ETHER);
- arp->ar_pro = htons (PROT_IP);
+ arp->ar_hrd = htons(ARP_ETHER);
+ arp->ar_pro = htons(PROT_IP);
arp->ar_hln = 6;
arp->ar_pln = 4;
- arp->ar_op = htons (ARPOP_REQUEST);
+ arp->ar_op = htons(ARPOP_REQUEST);
/* source ET addr */
- memcpy (&arp->ar_data[0], NetOurEther, 6);
+ memcpy(&arp->ar_data[0], NetOurEther, 6);
/* source IP addr */
- NetWriteIP ((uchar *) & arp->ar_data[6], NetOurIP);
+ NetWriteIP((uchar *) &arp->ar_data[6], NetOurIP);
for (i = 10; i < 16; ++i) {
/* dest ET addr = 0 */
arp->ar_data[i] = 0;
@@ -277,7 +277,7 @@ void ArpRequest (void)
if ((NetArpWaitPacketIP & NetOurSubnetMask) !=
(NetOurIP & NetOurSubnetMask)) {
if (NetOurGatewayIP == 0) {
- puts ("## Warning: gatewayip needed but not set\n");
+ puts("## Warning: gatewayip needed but not set\n");
NetArpWaitReplyIP = NetArpWaitPacketIP;
} else {
NetArpWaitReplyIP = NetOurGatewayIP;
@@ -286,8 +286,8 @@ void ArpRequest (void)
NetArpWaitReplyIP = NetArpWaitPacketIP;
}
- NetWriteIP ((uchar *) & arp->ar_data[16], NetArpWaitReplyIP);
- (void) eth_send (NetTxPacket, (pkt - NetTxPacket) + ARP_HDR_SIZE);
+ NetWriteIP((uchar *) &arp->ar_data[16], NetArpWaitReplyIP);
+ (void) eth_send(NetTxPacket, (pkt - NetTxPacket) + ARP_HDR_SIZE);
}
void ArpTimeoutCheck(void)
@@ -304,7 +304,7 @@ void ArpTimeoutCheck(void)
NetArpWaitTry++;
if (NetArpWaitTry >= ARP_TIMEOUT_COUNT) {
- puts ("\nARP Retry count exceeded; starting again\n");
+ puts("\nARP Retry count exceeded; starting again\n");
NetArpWaitTry = 0;
NetStartAgain();
} else {
@@ -319,14 +319,14 @@ NetInitLoop(proto_t protocol)
{
static int env_changed_id;
bd_t *bd = gd->bd;
- int env_id = get_env_id ();
+ int env_id = get_env_id();
/* update only when the environment has changed */
if (env_changed_id != env_id) {
NetCopyIP(&NetOurIP, &bd->bi_ip_addr);
- NetOurGatewayIP = getenv_IPaddr ("gatewayip");
- NetOurSubnetMask= getenv_IPaddr ("netmask");
- NetServerIP = getenv_IPaddr ("serverip");
+ NetOurGatewayIP = getenv_IPaddr("gatewayip");
+ NetOurSubnetMask = getenv_IPaddr("netmask");
+ NetServerIP = getenv_IPaddr("serverip");
NetOurNativeVLAN = getenv_VLAN("nvlan");
NetOurVLAN = getenv_VLAN("vlan");
#if defined(CONFIG_CMD_DNS)
@@ -391,7 +391,7 @@ NetLoop(proto_t protocol)
restart:
#ifdef CONFIG_NET_MULTI
- memcpy (NetOurEther, eth_get_dev()->enetaddr, 6);
+ memcpy(NetOurEther, eth_get_dev()->enetaddr, 6);
#else
eth_getenv_enetaddr("ethaddr", NetOurEther);
#endif
@@ -405,7 +405,7 @@ restart:
*/
NetInitLoop(protocol);
- switch (net_check_prereq (protocol)) {
+ switch (net_check_prereq(protocol)) {
case 1:
/* network not configured */
eth_halt();
@@ -438,14 +438,14 @@ restart:
case BOOTP:
BootpTry = 0;
NetOurIP = 0;
- BootpRequest ();
+ BootpRequest();
break;
#if defined(CONFIG_CMD_RARP)
case RARP:
RarpTry = 0;
NetOurIP = 0;
- RarpRequest ();
+ RarpRequest();
break;
#endif
#if defined(CONFIG_CMD_PING)
@@ -493,10 +493,10 @@ restart:
/*
* Echo the inverted link state to the fault LED.
*/
- if(miiphy_link(eth_get_dev()->name, CONFIG_SYS_FAULT_MII_ADDR)) {
- status_led_set (STATUS_LED_RED, STATUS_LED_OFF);
+ if (miiphy_link(eth_get_dev()->name, CONFIG_SYS_FAULT_MII_ADDR)) {
+ status_led_set(STATUS_LED_RED, STATUS_LED_OFF);
} else {
- status_led_set (STATUS_LED_RED, STATUS_LED_ON);
+ status_led_set(STATUS_LED_RED, STATUS_LED_ON);
}
#endif /* CONFIG_SYS_FAULT_ECHO_LINK_DOWN, ... */
#endif /* CONFIG_MII, ... */
@@ -524,7 +524,7 @@ restart:
*/
if (ctrlc()) {
eth_halt();
- puts ("\nAbort\n");
+ puts("\nAbort\n");
return (-1);
}
@@ -538,19 +538,19 @@ restart:
thand_f *x;
#if defined(CONFIG_MII) || defined(CONFIG_CMD_MII)
-# if defined(CONFIG_SYS_FAULT_ECHO_LINK_DOWN) && \
- defined(CONFIG_STATUS_LED) && \
- defined(STATUS_LED_RED)
+#if defined(CONFIG_SYS_FAULT_ECHO_LINK_DOWN) && \
+ defined(CONFIG_STATUS_LED) && \
+ defined(STATUS_LED_RED)
/*
* Echo the inverted link state to the fault LED.
*/
- if(miiphy_link(eth_get_dev()->name,
+ if (miiphy_link(eth_get_dev()->name,
CONFIG_SYS_FAULT_MII_ADDR)) {
- status_led_set (STATUS_LED_RED, STATUS_LED_OFF);
+ status_led_set(STATUS_LED_RED, STATUS_LED_OFF);
} else {
- status_led_set (STATUS_LED_RED, STATUS_LED_ON);
+ status_led_set(STATUS_LED_RED, STATUS_LED_ON);
}
-# endif /* CONFIG_SYS_FAULT_ECHO_LINK_DOWN, ... */
+#endif /* CONFIG_SYS_FAULT_ECHO_LINK_DOWN, ... */
#endif /* CONFIG_MII, ... */
x = timeHandler;
timeHandler = (thand_f *)0;
@@ -601,7 +601,7 @@ startAgainHandler(uchar * pkt, unsigned dest, unsigned src, unsigned len)
/* Totally ignore the packet */
}
-void NetStartAgain (void)
+void NetStartAgain(void)
{
char *nretry;
int retry_forever = 0;
@@ -629,19 +629,19 @@ void NetStartAgain (void)
NetTryCount++;
#ifndef CONFIG_NET_MULTI
- NetSetTimeout (10000UL, startAgainTimeout);
- NetSetHandler (startAgainHandler);
+ NetSetTimeout(10000UL, startAgainTimeout);
+ NetSetHandler(startAgainHandler);
#else /* !CONFIG_NET_MULTI*/
- eth_halt ();
+ eth_halt();
#if !defined(CONFIG_NET_DO_NOT_TRY_ANOTHER)
- eth_try_another (!NetRestarted);
+ eth_try_another(!NetRestarted);
#endif
- eth_init (gd->bd);
+ eth_init(gd->bd);
if (NetRestartWrap) {
NetRestartWrap = 0;
if (NetDevExists) {
- NetSetTimeout (10000UL, startAgainTimeout);
- NetSetHandler (startAgainHandler);
+ NetSetTimeout(10000UL, startAgainTimeout);
+ NetSetHandler(startAgainHandler);
} else {
NetState = NETLOOP_FAIL;
}
@@ -707,9 +707,9 @@ NetSendUDPPacket(uchar *ether, IPaddr_t dest, int dport, int sport, int len)
NetArpWaitPacketMAC = ether;
pkt = NetArpWaitTxPacket;
- pkt += NetSetEther (pkt, NetArpWaitPacketMAC, PROT_IP);
+ pkt += NetSetEther(pkt, NetArpWaitPacketMAC, PROT_IP);
- NetSetIP (pkt, dest, dport, sport, len);
+ NetSetIP(pkt, dest, dport, sport, len);
memcpy(pkt + IP_HDR_SIZE, (uchar *)NetTxPacket +
(pkt - (uchar *)NetArpWaitTxPacket) + IP_HDR_SIZE, len);
@@ -727,8 +727,8 @@ NetSendUDPPacket(uchar *ether, IPaddr_t dest, int dport, int sport, int len)
debug("sending UDP to %08lx/%pM\n", dest, ether);
pkt = (uchar *)NetTxPacket;
- pkt += NetSetEther (pkt, ether, PROT_IP);
- NetSetIP (pkt, dest, dport, sport, len);
+ pkt += NetSetEther(pkt, ether, PROT_IP);
+ NetSetIP(pkt, dest, dport, sport, len);
(void) eth_send(NetTxPacket, (pkt - NetTxPacket) + IP_HDR_SIZE + len);
return 0; /* transmitted */
@@ -796,14 +796,14 @@ int PingSend(void)
}
static void
-PingTimeout (void)
+PingTimeout(void)
{
eth_halt();
NetState = NETLOOP_FAIL; /* we did not get the reply */
}
static void
-PingHandler (uchar * pkt, unsigned dest, unsigned src, unsigned len)
+PingHandler(uchar * pkt, unsigned dest, unsigned src, unsigned len)
{
IPaddr_t tmp;
volatile IP_t *ip = (volatile IP_t *)pkt;
@@ -818,10 +818,10 @@ PingHandler (uchar * pkt, unsigned dest, unsigned src, unsigned len)
static void PingStart(void)
{
#if defined(CONFIG_NET_MULTI)
- printf ("Using %s device\n", eth_get_name());
+ printf("Using %s device\n", eth_get_name());
#endif /* CONFIG_NET_MULTI */
- NetSetTimeout (10000UL, PingTimeout);
- NetSetHandler (PingHandler);
+ NetSetTimeout(10000UL, PingTimeout);
+ NetSetHandler(PingHandler);
PingSend();
}
@@ -919,8 +919,8 @@ int CDPSendTrigger(void)
Ethernet_t *et;
int len;
ushort chksum;
-#if defined(CONFIG_CDP_DEVICE_ID) || defined(CONFIG_CDP_PORT_ID) || \
- defined(CONFIG_CDP_VERSION) || defined(CONFIG_CDP_PLATFORM)
+#if defined(CONFIG_CDP_DEVICE_ID) || defined(CONFIG_CDP_PORT_ID) || \
+ defined(CONFIG_CDP_VERSION) || defined(CONFIG_CDP_PLATFORM)
char buf[32];
#endif
@@ -1028,12 +1028,12 @@ int CDPSendTrigger(void)
}
static void
-CDPTimeout (void)
+CDPTimeout(void)
{
CDPSeq++;
if (CDPSeq < 3) {
- NetSetTimeout (CDP_TIMEOUT, CDPTimeout);
+ NetSetTimeout(CDP_TIMEOUT, CDPTimeout);
CDPSendTrigger();
return;
}
@@ -1046,7 +1046,7 @@ CDPTimeout (void)
}
static void
-CDPDummyHandler (uchar * pkt, unsigned dest, unsigned src, unsigned len)
+CDPDummyHandler(uchar * pkt, unsigned dest, unsigned src, unsigned len)
{
/* nothing */
}
@@ -1171,7 +1171,7 @@ CDPHandler(const uchar * pkt, unsigned len)
static void CDPStart(void)
{
#if defined(CONFIG_NET_MULTI)
- printf ("Using %s device\n", eth_get_name());
+ printf("Using %s device\n", eth_get_name());
#endif
CDPSeq = 0;
CDPOK = 0;
@@ -1179,8 +1179,8 @@ static void CDPStart(void)
CDPNativeVLAN = htons(-1);
CDPApplianceVLAN = htons(-1);
- NetSetTimeout (CDP_TIMEOUT, CDPTimeout);
- NetSetHandler (CDPDummyHandler);
+ NetSetTimeout(CDP_TIMEOUT, CDPTimeout);
+ NetSetHandler(CDPDummyHandler);
CDPSendTrigger();
}
@@ -1284,7 +1284,7 @@ static IP_t *__NetDefragment(IP_t *ip, int *lenp)
* (thus being a superset of a previously-received fragment).
*/
- if ( (h >= thisfrag) && (h->last_byte <= start + len) ) {
+ if ((h >= thisfrag) && (h->last_byte <= start + len)) {
/* complete overlap with hole: remove hole */
if (!h->prev_hole && !h->next_hole) {
/* last remaining hole */
@@ -1507,10 +1507,10 @@ NetReceive(volatile uchar * inpkt, int len)
pkt = (uchar *)et;
pkt += NetSetEther(pkt, et->et_src, PROT_ARP);
arp->ar_op = htons(ARPOP_REPLY);
- memcpy (&arp->ar_data[10], &arp->ar_data[0], 6);
+ memcpy(&arp->ar_data[10], &arp->ar_data[0], 6);
NetCopyIP(&arp->ar_data[16], &arp->ar_data[6]);
- memcpy (&arp->ar_data[ 0], NetOurEther, 6);
- NetCopyIP(&arp->ar_data[ 6], &NetOurIP);
+ memcpy(&arp->ar_data[0], NetOurEther, 6);
+ NetCopyIP(&arp->ar_data[6], &NetOurIP);
(void) eth_send((uchar *)et,
(pkt - (uchar *)et) + ARP_HDR_SIZE);
return;
@@ -1541,7 +1541,7 @@ NetReceive(volatile uchar * inpkt, int len)
&arp->ar_data[0], 6);
#ifdef CONFIG_NETCONSOLE
- (*packetHandler)(0,0,0,0);
+ (*packetHandler)(0, 0, 0, 0);
#endif
/* modify header, and transmit it */
memcpy(((Ethernet_t *)NetArpWaitTxPacket)->et_dest, NetArpWaitPacketMAC, 6);
@@ -1576,14 +1576,14 @@ NetReceive(volatile uchar * inpkt, int len)
(ntohs(arp->ar_pro) != PROT_IP) ||
(arp->ar_hln != 6) || (arp->ar_pln != 4)) {
- puts ("invalid RARP header\n");
+ puts("invalid RARP header\n");
} else {
NetCopyIP(&NetOurIP, &arp->ar_data[16]);
if (NetServerIP == 0)
- NetCopyIP(&NetServerIP, &arp->ar_data[ 6]);
- memcpy (NetServerEther, &arp->ar_data[ 0], 6);
+ NetCopyIP(&NetServerIP, &arp->ar_data[6]);
+ memcpy(NetServerEther, &arp->ar_data[0], 6);
- (*packetHandler)(0,0,0,0);
+ (*packetHandler)(0, 0, 0, 0);
}
break;
#endif
@@ -1612,7 +1612,7 @@ NetReceive(volatile uchar * inpkt, int len)
}
/* Check the Checksum of the header */
if (!NetCksumOk((uchar *)ip, IP_HDR_SIZE_NO_UDP / 2)) {
- puts ("checksum bad\n");
+ puts("checksum bad\n");
return;
}
/* If it is not for us, ignore it */
@@ -1654,7 +1654,7 @@ NetReceive(volatile uchar * inpkt, int len)
case ICMP_REDIRECT:
if (icmph->code != ICMP_REDIR_HOST)
return;
- printf (" ICMP Host Redirect to %pI4 ",
+ printf(" ICMP Host Redirect to %pI4 ",
&icmph->un.gateway);
return;
#if defined(CONFIG_CMD_PING)
@@ -1668,11 +1668,11 @@ NetReceive(volatile uchar * inpkt, int len)
return;
case ICMP_ECHO_REQUEST:
debug("Got ICMP ECHO REQUEST, "
- "return %d bytes \n",
+ "return %d bytes\n",
ETHER_HDR_SIZE + len);
- memcpy (&et->et_dest[0], &et->et_src[0], 6);
- memcpy (&et->et_src[ 0], NetOurEther, 6);
+ memcpy(&et->et_dest[0], &et->et_src[0], 6);
+ memcpy(&et->et_src[0], NetOurEther, 6);
ip->ip_sum = 0;
ip->ip_off = 0;
@@ -1740,7 +1740,7 @@ NetReceive(volatile uchar * inpkt, int len)
#ifdef CONFIG_NETCONSOLE
- nc_input_packet((uchar *)ip +IP_HDR_SIZE,
+ nc_input_packet((uchar *)ip + IP_HDR_SIZE,
ntohs(ip->udp_dst),
ntohs(ip->udp_src),
ntohs(ip->udp_len) - 8);
@@ -1748,7 +1748,7 @@ NetReceive(volatile uchar * inpkt, int len)
/*
* IP header OK. Pass the packet to the current handler.
*/
- (*packetHandler)((uchar *)ip +IP_HDR_SIZE,
+ (*packetHandler)((uchar *)ip + IP_HDR_SIZE,
ntohs(ip->udp_dst),
ntohs(ip->udp_src),
ntohs(ip->udp_len) - 8);
@@ -1759,14 +1759,14 @@ NetReceive(volatile uchar * inpkt, int len)
/**********************************************************************/
-static int net_check_prereq (proto_t protocol)
+static int net_check_prereq(proto_t protocol)
{
switch (protocol) {
/* Fall through */
#if defined(CONFIG_CMD_PING)
case PING:
if (NetPingIP == 0) {
- puts ("*** ERROR: ping address not given\n");
+ puts("*** ERROR: ping address not given\n");
return (1);
}
goto common;
@@ -1774,7 +1774,7 @@ static int net_check_prereq (proto_t protocol)
#if defined(CONFIG_CMD_SNTP)
case SNTP:
if (NetNtpServerIP == 0) {
- puts ("*** ERROR: NTP server address not given\n");
+ puts("*** ERROR: NTP server address not given\n");
return (1);
}
goto common;
@@ -1793,16 +1793,16 @@ static int net_check_prereq (proto_t protocol)
case NETCONS:
case TFTP:
if (NetServerIP == 0) {
- puts ("*** ERROR: `serverip' not set\n");
+ puts("*** ERROR: `serverip' not set\n");
return (1);
}
-#if defined(CONFIG_CMD_PING) || defined(CONFIG_CMD_SNTP) || \
- defined(CONFIG_CMD_DNS)
+#if defined(CONFIG_CMD_PING) || defined(CONFIG_CMD_SNTP) || \
+ defined(CONFIG_CMD_DNS)
common:
#endif
if (NetOurIP == 0) {
- puts ("*** ERROR: `ipaddr' not set\n");
+ puts("*** ERROR: `ipaddr' not set\n");
return (1);
}
/* Fall through */
@@ -1813,28 +1813,28 @@ static int net_check_prereq (proto_t protocol)
case BOOTP:
case CDP:
case DHCP:
- if (memcmp (NetOurEther, "\0\0\0\0\0\0", 6) == 0) {
+ if (memcmp(NetOurEther, "\0\0\0\0\0\0", 6) == 0) {
#ifdef CONFIG_NET_MULTI
- extern int eth_get_dev_index (void);
- int num = eth_get_dev_index ();
+ extern int eth_get_dev_index(void);
+ int num = eth_get_dev_index();
switch (num) {
case -1:
- puts ("*** ERROR: No ethernet found.\n");
+ puts("*** ERROR: No ethernet found.\n");
return (1);
case 0:
- puts ("*** ERROR: `ethaddr' not set\n");
+ puts("*** ERROR: `ethaddr' not set\n");
break;
default:
- printf ("*** ERROR: `eth%daddr' not set\n",
+ printf("*** ERROR: `eth%daddr' not set\n",
num);
break;
}
- NetStartAgain ();
+ NetStartAgain();
return (2);
#else
- puts ("*** ERROR: `ethaddr' not set\n");
+ puts("*** ERROR: `ethaddr' not set\n");
return (1);
#endif
}
@@ -1890,8 +1890,8 @@ NetSetEther(volatile uchar * xet, uchar * addr, uint prot)
if (myvlanid == (ushort)-1)
myvlanid = VLAN_NONE;
- memcpy (et->et_dest, addr, 6);
- memcpy (et->et_src, NetOurEther, 6);
+ memcpy(et->et_dest, addr, 6);
+ memcpy(et->et_src, NetOurEther, 6);
if ((myvlanid & VLAN_IDMASK) == VLAN_NONE) {
et->et_protlen = htons(prot);
return ETHER_HDR_SIZE;
@@ -1942,7 +1942,7 @@ NetSetIP(volatile uchar * xip, IPaddr_t dest, int dport, int sport, int len)
ip->ip_sum = ~NetCksum((uchar *)ip, IP_HDR_SIZE_NO_UDP / 2);
}
-void copy_filename (char *dst, const char *src, int size)
+void copy_filename(char *dst, const char *src, int size)
{
if (*src && (*src == '"')) {
++src;
@@ -1969,13 +1969,13 @@ unsigned int random_port(void)
}
#endif
-void ip_to_string (IPaddr_t x, char *s)
+void ip_to_string(IPaddr_t x, char *s)
{
- x = ntohl (x);
- sprintf (s, "%d.%d.%d.%d",
- (int) ((x >> 24) & 0xff),
- (int) ((x >> 16) & 0xff),
- (int) ((x >> 8) & 0xff), (int) ((x >> 0) & 0xff)
+ x = ntohl(x);
+ sprintf(s, "%d.%d.%d.%d",
+ (int) ((x >> 24) & 0xff),
+ (int) ((x >> 16) & 0xff),
+ (int) ((x >> 8) & 0xff), (int) ((x >> 0) & 0xff)
);
}
--
1.7.1
^ permalink raw reply related [flat|nested] 32+ messages in thread
* [U-Boot] [PATCH 4/8] net/net.c: cosmetic: fix brace issues
2011-05-04 12:40 [U-Boot] [PATCH 0/8] net/net.c: clenups for checkpatch compliance Luca Ceresoli
` (2 preceding siblings ...)
2011-05-04 12:40 ` [U-Boot] [PATCH 3/8] net/net.c: cosmetic: fix whitespace issues Luca Ceresoli
@ 2011-05-04 12:40 ` Luca Ceresoli
2011-05-04 12:40 ` [U-Boot] [PATCH 5/8] net/net.c: cosmetic: fix pointer syntax issues Luca Ceresoli
` (12 subsequent siblings)
16 siblings, 0 replies; 32+ messages in thread
From: Luca Ceresoli @ 2011-05-04 12:40 UTC (permalink / raw)
To: u-boot
This removes the following checkpatch issues:
- WARNING: braces {} are not necessary for single statement blocks
- WARNING: braces {} are not necessary for any arm of this statement
Signed-off-by: Luca Ceresoli <luca.ceresoli@comelit.it>
Cc: Wolfgang Denk <wd@denx.de>
Cc: Ben Warren <biggerbadderben@gmail.com>
---
net/net.c | 38 +++++++++++++-------------------------
1 files changed, 13 insertions(+), 25 deletions(-)
diff --git a/net/net.c b/net/net.c
index 630aeee..14dc65a 100644
--- a/net/net.c
+++ b/net/net.c
@@ -369,9 +369,8 @@ NetLoop(proto_t protocol)
*/
NetTxPacket = &PktBuf[0] + (PKTALIGN - 1);
NetTxPacket -= (ulong)NetTxPacket % PKTALIGN;
- for (i = 0; i < PKTBUFSRX; i++) {
+ for (i = 0; i < PKTBUFSRX; i++)
NetRxPackets[i] = NetTxPacket + (i+1)*PKTSIZE_ALIGN;
- }
}
if (!NetArpWaitTxPacket) {
@@ -493,11 +492,10 @@ restart:
/*
* Echo the inverted link state to the fault LED.
*/
- if (miiphy_link(eth_get_dev()->name, CONFIG_SYS_FAULT_MII_ADDR)) {
+ if (miiphy_link(eth_get_dev()->name, CONFIG_SYS_FAULT_MII_ADDR))
status_led_set(STATUS_LED_RED, STATUS_LED_OFF);
- } else {
+ else
status_led_set(STATUS_LED_RED, STATUS_LED_ON);
- }
#endif /* CONFIG_SYS_FAULT_ECHO_LINK_DOWN, ... */
#endif /* CONFIG_MII, ... */
@@ -1098,9 +1096,8 @@ CDPHandler(const uchar * pkt, unsigned len)
ss = (const ushort *)pkt;
type = ntohs(ss[0]);
tlen = ntohs(ss[1]);
- if (tlen > len) {
+ if (tlen > len)
goto pkt_short;
- }
pkt += tlen;
len -= tlen;
@@ -1479,26 +1476,20 @@ NetReceive(volatile uchar * inpkt, int len)
printf("bad length %d < %d\n", len, ARP_HDR_SIZE);
return;
}
- if (ntohs(arp->ar_hrd) != ARP_ETHER) {
+ if (ntohs(arp->ar_hrd) != ARP_ETHER)
return;
- }
- if (ntohs(arp->ar_pro) != PROT_IP) {
+ if (ntohs(arp->ar_pro) != PROT_IP)
return;
- }
- if (arp->ar_hln != 6) {
+ if (arp->ar_hln != 6)
return;
- }
- if (arp->ar_pln != 4) {
+ if (arp->ar_pln != 4)
return;
- }
- if (NetOurIP == 0) {
+ if (NetOurIP == 0)
return;
- }
- if (NetReadIP(&arp->ar_data[16]) != NetOurIP) {
+ if (NetReadIP(&arp->ar_data[16]) != NetOurIP)
return;
- }
switch (ntohs(arp->ar_op)) {
case ARPOP_REQUEST:
@@ -1603,13 +1594,11 @@ NetReceive(volatile uchar * inpkt, int len)
debug("len=%d, v=%02x\n", len, ip->ip_hl_v & 0xff);
/* Can't deal with anything except IPv4 */
- if ((ip->ip_hl_v & 0xf0) != 0x40) {
+ if ((ip->ip_hl_v & 0xf0) != 0x40)
return;
- }
/* Can't deal with IP options (headers != 20 bytes) */
- if ((ip->ip_hl_v & 0x0f) > 0x05) {
+ if ((ip->ip_hl_v & 0x0f) > 0x05)
return;
- }
/* Check the Checksum of the header */
if (!NetCksumOk((uchar *)ip, IP_HDR_SIZE_NO_UDP / 2)) {
puts("checksum bad\n");
@@ -1949,9 +1938,8 @@ void copy_filename(char *dst, const char *src, int size)
--size;
}
- while ((--size > 0) && *src && (*src != '"')) {
+ while ((--size > 0) && *src && (*src != '"'))
*dst++ = *src++;
- }
*dst = '\0';
}
--
1.7.1
^ permalink raw reply related [flat|nested] 32+ messages in thread
* [U-Boot] [PATCH 5/8] net/net.c: cosmetic: fix pointer syntax issues
2011-05-04 12:40 [U-Boot] [PATCH 0/8] net/net.c: clenups for checkpatch compliance Luca Ceresoli
` (3 preceding siblings ...)
2011-05-04 12:40 ` [U-Boot] [PATCH 4/8] net/net.c: cosmetic: fix brace issues Luca Ceresoli
@ 2011-05-04 12:40 ` Luca Ceresoli
2011-05-04 12:40 ` [U-Boot] [PATCH 6/8] net/net.c: cosmetic: parentheses not required for return Luca Ceresoli
` (11 subsequent siblings)
16 siblings, 0 replies; 32+ messages in thread
From: Luca Ceresoli @ 2011-05-04 12:40 UTC (permalink / raw)
To: u-boot
This removes the following checkpatch issues:
- ERROR: "foo * bar" should be "foo *bar"
- ERROR: "(foo*)" should be "(foo *)"
Signed-off-by: Luca Ceresoli <luca.ceresoli@comelit.it>
Cc: Wolfgang Denk <wd@denx.de>
Cc: Ben Warren <biggerbadderben@gmail.com>
---
net/net.c | 36 ++++++++++++++++++------------------
1 files changed, 18 insertions(+), 18 deletions(-)
diff --git a/net/net.c b/net/net.c
index 14dc65a..0e13fb2 100644
--- a/net/net.c
+++ b/net/net.c
@@ -594,7 +594,7 @@ startAgainTimeout(void)
}
static void
-startAgainHandler(uchar * pkt, unsigned dest, unsigned src, unsigned len)
+startAgainHandler(uchar *pkt, unsigned dest, unsigned src, unsigned len)
{
/* Totally ignore the packet */
}
@@ -655,14 +655,14 @@ void NetStartAgain(void)
*/
void
-NetSetHandler(rxhand_f * f)
+NetSetHandler(rxhand_f *f)
{
packetHandler = f;
}
void
-NetSetTimeout(ulong iv, thand_f * f)
+NetSetTimeout(ulong iv, thand_f *f)
{
if (iv == 0) {
timeHandler = (thand_f *)0;
@@ -675,7 +675,7 @@ NetSetTimeout(ulong iv, thand_f * f)
void
-NetSendPacket(volatile uchar * pkt, int len)
+NetSendPacket(volatile uchar *pkt, int len)
{
(void) eth_send(pkt, len);
}
@@ -770,9 +770,9 @@ int PingSend(void)
ip->ip_p = 0x01; /* ICMP */
ip->ip_sum = 0;
/* already in network byte order */
- NetCopyIP((void*)&ip->ip_src, &NetOurIP);
+ NetCopyIP((void *)&ip->ip_src, &NetOurIP);
/* - "" - */
- NetCopyIP((void*)&ip->ip_dst, &NetPingIP);
+ NetCopyIP((void *)&ip->ip_dst, &NetPingIP);
ip->ip_sum = ~NetCksum((uchar *)ip, IP_HDR_SIZE_NO_UDP / 2);
s = &ip->udp_src; /* XXX ICMP starts here */
@@ -801,7 +801,7 @@ PingTimeout(void)
}
static void
-PingHandler(uchar * pkt, unsigned dest, unsigned src, unsigned len)
+PingHandler(uchar *pkt, unsigned dest, unsigned src, unsigned len)
{
IPaddr_t tmp;
volatile IP_t *ip = (volatile IP_t *)pkt;
@@ -1044,13 +1044,13 @@ CDPTimeout(void)
}
static void
-CDPDummyHandler(uchar * pkt, unsigned dest, unsigned src, unsigned len)
+CDPDummyHandler(uchar *pkt, unsigned dest, unsigned src, unsigned len)
{
/* nothing */
}
static void
-CDPHandler(const uchar * pkt, unsigned len)
+CDPHandler(const uchar *pkt, unsigned len)
{
const uchar *t;
const ushort *ss;
@@ -1356,7 +1356,7 @@ static inline IP_t *NetDefragment(IP_t *ip, int *lenp)
#endif
void
-NetReceive(volatile uchar * inpkt, int len)
+NetReceive(volatile uchar *inpkt, int len)
{
Ethernet_t *et;
IP_t *ip;
@@ -1665,8 +1665,8 @@ NetReceive(volatile uchar * inpkt, int len)
ip->ip_sum = 0;
ip->ip_off = 0;
- NetCopyIP((void*)&ip->ip_dst, &ip->ip_src);
- NetCopyIP((void*)&ip->ip_src, &NetOurIP);
+ NetCopyIP((void *)&ip->ip_dst, &ip->ip_src);
+ NetCopyIP((void *)&ip->ip_src, &NetOurIP);
ip->ip_sum = ~NetCksum((uchar *)ip,
IP_HDR_SIZE_NO_UDP >> 1);
@@ -1836,14 +1836,14 @@ static int net_check_prereq(proto_t protocol)
/**********************************************************************/
int
-NetCksumOk(uchar * ptr, int len)
+NetCksumOk(uchar *ptr, int len)
{
return !((NetCksum(ptr, len) + 1) & 0xfffe);
}
unsigned
-NetCksum(uchar * ptr, int len)
+NetCksum(uchar *ptr, int len)
{
ulong xsum;
ushort *p = (ushort *)ptr;
@@ -1870,7 +1870,7 @@ NetEthHdrSize(void)
}
int
-NetSetEther(volatile uchar * xet, uchar * addr, uint prot)
+NetSetEther(volatile uchar *xet, uchar * addr, uint prot)
{
Ethernet_t *et = (Ethernet_t *)xet;
ushort myvlanid;
@@ -1895,7 +1895,7 @@ NetSetEther(volatile uchar * xet, uchar * addr, uint prot)
}
void
-NetSetIP(volatile uchar * xip, IPaddr_t dest, int dport, int sport, int len)
+NetSetIP(volatile uchar *xip, IPaddr_t dest, int dport, int sport, int len)
{
IP_t *ip = (IP_t *)xip;
@@ -1921,9 +1921,9 @@ NetSetIP(volatile uchar * xip, IPaddr_t dest, int dport, int sport, int len)
ip->ip_p = 17; /* UDP */
ip->ip_sum = 0;
/* already in network byte order */
- NetCopyIP((void*)&ip->ip_src, &NetOurIP);
+ NetCopyIP((void *)&ip->ip_src, &NetOurIP);
/* - "" - */
- NetCopyIP((void*)&ip->ip_dst, &dest);
+ NetCopyIP((void *)&ip->ip_dst, &dest);
ip->udp_src = htons(sport);
ip->udp_dst = htons(dport);
ip->udp_len = htons(8 + len);
--
1.7.1
^ permalink raw reply related [flat|nested] 32+ messages in thread
* [U-Boot] [PATCH 6/8] net/net.c: cosmetic: parentheses not required for return
2011-05-04 12:40 [U-Boot] [PATCH 0/8] net/net.c: clenups for checkpatch compliance Luca Ceresoli
` (4 preceding siblings ...)
2011-05-04 12:40 ` [U-Boot] [PATCH 5/8] net/net.c: cosmetic: fix pointer syntax issues Luca Ceresoli
@ 2011-05-04 12:40 ` Luca Ceresoli
2011-05-04 12:40 ` [U-Boot] [PATCH 7/8] net/net.c: cosmetic: fix indentation Luca Ceresoli
` (10 subsequent siblings)
16 siblings, 0 replies; 32+ messages in thread
From: Luca Ceresoli @ 2011-05-04 12:40 UTC (permalink / raw)
To: u-boot
This removes the following checkpatch issue:
- ERROR: return is not a function, parentheses are not required
Signed-off-by: Luca Ceresoli <luca.ceresoli@comelit.it>
Cc: Wolfgang Denk <wd@denx.de>
Cc: Ben Warren <biggerbadderben@gmail.com>
---
net/net.c | 30 +++++++++++++++---------------
1 files changed, 15 insertions(+), 15 deletions(-)
diff --git a/net/net.c b/net/net.c
index 0e13fb2..2bffc5b 100644
--- a/net/net.c
+++ b/net/net.c
@@ -385,7 +385,7 @@ NetLoop(proto_t protocol)
#endif
if (eth_init(bd) < 0) {
eth_halt();
- return(-1);
+ return -1;
}
restart:
@@ -408,7 +408,7 @@ restart:
case 1:
/* network not configured */
eth_halt();
- return (-1);
+ return -1;
#ifdef CONFIG_NET_MULTI
case 2:
@@ -523,7 +523,7 @@ restart:
if (ctrlc()) {
eth_halt();
puts("\nAbort\n");
- return (-1);
+ return -1;
}
ArpTimeoutCheck();
@@ -580,7 +580,7 @@ restart:
return NetBootFileXferSize;
case NETLOOP_FAIL:
- return (-1);
+ return -1;
}
}
}
@@ -1756,7 +1756,7 @@ static int net_check_prereq(proto_t protocol)
case PING:
if (NetPingIP == 0) {
puts("*** ERROR: ping address not given\n");
- return (1);
+ return 1;
}
goto common;
#endif
@@ -1764,7 +1764,7 @@ static int net_check_prereq(proto_t protocol)
case SNTP:
if (NetNtpServerIP == 0) {
puts("*** ERROR: NTP server address not given\n");
- return (1);
+ return 1;
}
goto common;
#endif
@@ -1783,7 +1783,7 @@ static int net_check_prereq(proto_t protocol)
case TFTP:
if (NetServerIP == 0) {
puts("*** ERROR: `serverip' not set\n");
- return (1);
+ return 1;
}
#if defined(CONFIG_CMD_PING) || defined(CONFIG_CMD_SNTP) || \
defined(CONFIG_CMD_DNS)
@@ -1792,7 +1792,7 @@ static int net_check_prereq(proto_t protocol)
if (NetOurIP == 0) {
puts("*** ERROR: `ipaddr' not set\n");
- return (1);
+ return 1;
}
/* Fall through */
@@ -1810,7 +1810,7 @@ static int net_check_prereq(proto_t protocol)
switch (num) {
case -1:
puts("*** ERROR: No ethernet found.\n");
- return (1);
+ return 1;
case 0:
puts("*** ERROR: `ethaddr' not set\n");
break;
@@ -1821,17 +1821,17 @@ static int net_check_prereq(proto_t protocol)
}
NetStartAgain();
- return (2);
+ return 2;
#else
puts("*** ERROR: `ethaddr' not set\n");
- return (1);
+ return 1;
#endif
}
/* Fall through */
default:
- return (0);
+ return 0;
}
- return (0); /* OK */
+ return 0; /* OK */
}
/**********************************************************************/
@@ -1853,7 +1853,7 @@ NetCksum(uchar *ptr, int len)
xsum += *p++;
xsum = (xsum & 0xffff) + (xsum >> 16);
xsum = (xsum & 0xffff) + (xsum >> 16);
- return (xsum & 0xffff);
+ return xsum & 0xffff;
}
int
@@ -1997,5 +1997,5 @@ ushort string_to_VLAN(const char *s)
ushort getenv_VLAN(char *var)
{
- return (string_to_VLAN(getenv(var)));
+ return string_to_VLAN(getenv(var));
}
--
1.7.1
^ permalink raw reply related [flat|nested] 32+ messages in thread
* [U-Boot] [PATCH 7/8] net/net.c: cosmetic: fix indentation
2011-05-04 12:40 [U-Boot] [PATCH 0/8] net/net.c: clenups for checkpatch compliance Luca Ceresoli
` (5 preceding siblings ...)
2011-05-04 12:40 ` [U-Boot] [PATCH 6/8] net/net.c: cosmetic: parentheses not required for return Luca Ceresoli
@ 2011-05-04 12:40 ` Luca Ceresoli
2011-05-04 12:40 ` [U-Boot] [PATCH 8/8] net/net.c: cosmetic: do not use assignment in if condition Luca Ceresoli
` (9 subsequent siblings)
16 siblings, 0 replies; 32+ messages in thread
From: Luca Ceresoli @ 2011-05-04 12:40 UTC (permalink / raw)
To: u-boot
This removes the following checkpatch issues:
- ERROR: switch and case should be at the same indent
- WARNING: suspect code indent for conditional statements
- WARNING: labels should not be indented
Signed-off-by: Luca Ceresoli <luca.ceresoli@comelit.it>
Cc: Wolfgang Denk <wd@denx.de>
Cc: Ben Warren <biggerbadderben@gmail.com>
---
net/net.c | 85 ++++++++++++++++++++++++++++++-------------------------------
1 files changed, 42 insertions(+), 43 deletions(-)
diff --git a/net/net.c b/net/net.c
index 2bffc5b..13efa67 100644
--- a/net/net.c
+++ b/net/net.c
@@ -1106,51 +1106,50 @@ CDPHandler(const uchar *pkt, unsigned len)
tlen -= 4;
switch (type) {
- case CDP_DEVICE_ID_TLV:
- break;
- case CDP_ADDRESS_TLV:
- break;
- case CDP_PORT_ID_TLV:
- break;
- case CDP_CAPABILITIES_TLV:
- break;
- case CDP_VERSION_TLV:
- break;
- case CDP_PLATFORM_TLV:
- break;
- case CDP_NATIVE_VLAN_TLV:
- nvlan = *ss;
- break;
- case CDP_APPLIANCE_VLAN_TLV:
- t = (const uchar *)ss;
- while (tlen > 0) {
- if (tlen < 3)
- goto pkt_short;
+ case CDP_DEVICE_ID_TLV:
+ break;
+ case CDP_ADDRESS_TLV:
+ break;
+ case CDP_PORT_ID_TLV:
+ break;
+ case CDP_CAPABILITIES_TLV:
+ break;
+ case CDP_VERSION_TLV:
+ break;
+ case CDP_PLATFORM_TLV:
+ break;
+ case CDP_NATIVE_VLAN_TLV:
+ nvlan = *ss;
+ break;
+ case CDP_APPLIANCE_VLAN_TLV:
+ t = (const uchar *)ss;
+ while (tlen > 0) {
+ if (tlen < 3)
+ goto pkt_short;
- applid = t[0];
- ss = (const ushort *)(t + 1);
+ applid = t[0];
+ ss = (const ushort *)(t + 1);
#ifdef CONFIG_CDP_APPLIANCE_VLAN_TYPE
- if (applid ==
- CONFIG_CDP_APPLIANCE_VLAN_TYPE)
- vlan = *ss;
+ if (applid == CONFIG_CDP_APPLIANCE_VLAN_TYPE)
+ vlan = *ss;
#else
- /* XXX will this work; dunno */
- vlan = ntohs(*ss);
+ /* XXX will this work; dunno */
+ vlan = ntohs(*ss);
#endif
- t += 3; tlen -= 3;
- }
- break;
- case CDP_TRIGGER_TLV:
- break;
- case CDP_POWER_CONSUMPTION_TLV:
- break;
- case CDP_SYSNAME_TLV:
- break;
- case CDP_SYSOBJECT_TLV:
- break;
- case CDP_MANAGEMENT_ADDRESS_TLV:
- break;
+ t += 3; tlen -= 3;
+ }
+ break;
+ case CDP_TRIGGER_TLV:
+ break;
+ case CDP_POWER_CONSUMPTION_TLV:
+ break;
+ case CDP_SYSNAME_TLV:
+ break;
+ case CDP_SYSOBJECT_TLV:
+ break;
+ case CDP_MANAGEMENT_ADDRESS_TLV:
+ break;
}
}
@@ -1610,7 +1609,7 @@ NetReceive(volatile uchar *inpkt, int len)
#ifdef CONFIG_MCAST_TFTP
if (Mcast_addr != tmp)
#endif
- return;
+ return;
}
/*
* The function returns the unchanged packet if it's not
@@ -1787,7 +1786,7 @@ static int net_check_prereq(proto_t protocol)
}
#if defined(CONFIG_CMD_PING) || defined(CONFIG_CMD_SNTP) || \
defined(CONFIG_CMD_DNS)
- common:
+common:
#endif
if (NetOurIP == 0) {
@@ -1882,7 +1881,7 @@ NetSetEther(volatile uchar *xet, uchar * addr, uint prot)
memcpy(et->et_dest, addr, 6);
memcpy(et->et_src, NetOurEther, 6);
if ((myvlanid & VLAN_IDMASK) == VLAN_NONE) {
- et->et_protlen = htons(prot);
+ et->et_protlen = htons(prot);
return ETHER_HDR_SIZE;
} else {
VLAN_Ethernet_t *vet = (VLAN_Ethernet_t *)xet;
--
1.7.1
^ permalink raw reply related [flat|nested] 32+ messages in thread
* [U-Boot] [PATCH 8/8] net/net.c: cosmetic: do not use assignment in if condition
2011-05-04 12:40 [U-Boot] [PATCH 0/8] net/net.c: clenups for checkpatch compliance Luca Ceresoli
` (6 preceding siblings ...)
2011-05-04 12:40 ` [U-Boot] [PATCH 7/8] net/net.c: cosmetic: fix indentation Luca Ceresoli
@ 2011-05-04 12:40 ` Luca Ceresoli
2011-05-11 13:59 ` [U-Boot] [PATCH v2 0/8] net/net.c: cleanups for checkpatch compliance Luca Ceresoli
` (8 subsequent siblings)
16 siblings, 0 replies; 32+ messages in thread
From: Luca Ceresoli @ 2011-05-04 12:40 UTC (permalink / raw)
To: u-boot
This removes the following checkpatch issue:
- ERROR: do not use assignment in if condition
Signed-off-by: Luca Ceresoli <luca.ceresoli@comelit.it>
Cc: Wolfgang Denk <wd@denx.de>
Cc: Ben Warren <biggerbadderben@gmail.com>
---
net/net.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/net/net.c b/net/net.c
index 13efa67..c17d071 100644
--- a/net/net.c
+++ b/net/net.c
@@ -1616,7 +1616,8 @@ NetReceive(volatile uchar *inpkt, int len)
* a fragment, and either the complete packet or NULL if
* it is a fragment (if !CONFIG_IP_DEFRAG, it returns NULL)
*/
- if (!(ip = NetDefragment(ip, &len)))
+ ip = NetDefragment(ip, &len);
+ if (!ip)
return;
/*
* watch for ICMP host redirects
--
1.7.1
^ permalink raw reply related [flat|nested] 32+ messages in thread
* [U-Boot] [PATCH 2/8] net/net.c: cosmetic: variable initializations
2011-05-04 12:40 ` [U-Boot] [PATCH 2/8] net/net.c: cosmetic: variable initializations Luca Ceresoli
@ 2011-05-04 13:16 ` Mike Frysinger
2011-05-04 16:42 ` Luca Ceresoli
0 siblings, 1 reply; 32+ messages in thread
From: Mike Frysinger @ 2011-05-04 13:16 UTC (permalink / raw)
To: u-boot
On Wed, May 4, 2011 at 08:40, Luca Ceresoli wrote:
> ?- ERROR: that open brace { should be on the previous line
>...
> -uchar NetCDPAddr[6] =
> - { 0x01, 0x00, 0x0c, 0xcc, 0xcc, 0xcc };
> +uchar NetCDPAddr[6] = {
> + 0x01, 0x00, 0x0c, 0xcc, 0xcc, 0xcc };
>...
your fix here is worse than the original. just leave them be.
-mike
^ permalink raw reply [flat|nested] 32+ messages in thread
* [U-Boot] [PATCH 2/8] net/net.c: cosmetic: variable initializations
2011-05-04 13:16 ` Mike Frysinger
@ 2011-05-04 16:42 ` Luca Ceresoli
2011-05-05 7:54 ` Mike Frysinger
0 siblings, 1 reply; 32+ messages in thread
From: Luca Ceresoli @ 2011-05-04 16:42 UTC (permalink / raw)
To: u-boot
Mike Frysinger wrote:
> On Wed, May 4, 2011 at 08:40, Luca Ceresoli wrote:
>> - ERROR: that open brace { should be on the previous line
>> ...
>> -uchar NetCDPAddr[6] =
>> - { 0x01, 0x00, 0x0c, 0xcc, 0xcc, 0xcc };
>> +uchar NetCDPAddr[6] = {
>> + 0x01, 0x00, 0x0c, 0xcc, 0xcc, 0xcc };
>> ...
> your fix here is worse than the original. just leave them be.
Damn, you're right!
I think a one-line solution would be even better (and much simpler):
uchar NetCDPAddr[6] = {0x01, 0x00, 0x0c, 0xcc, 0xcc, 0xcc};
BTW, this is the original checkpatch message:
ERROR: that open brace { should be on the previous line
#172: FILE: net.c:172:
+uchar NetCDPAddr[6] =
+ { 0x01, 0x00, 0x0c, 0xcc, 0xcc, 0xcc };
So either we choose the one-line solution above, or we have the first
checkpatch message that should be disabled in the U-Boot version, when it
will exist.
Your opinion?
Luca
^ permalink raw reply [flat|nested] 32+ messages in thread
* [U-Boot] [PATCH 2/8] net/net.c: cosmetic: variable initializations
2011-05-04 16:42 ` Luca Ceresoli
@ 2011-05-05 7:54 ` Mike Frysinger
0 siblings, 0 replies; 32+ messages in thread
From: Mike Frysinger @ 2011-05-05 7:54 UTC (permalink / raw)
To: u-boot
On Wed, May 4, 2011 at 12:42, Luca Ceresoli wrote:
> Mike Frysinger wrote:
>> On Wed, May 4, 2011 at 08:40, Luca Ceresoli wrote:
>>>
>>> ?- ERROR: that open brace { should be on the previous line
>>> ...
>>> -uchar ? ? ? ? ?NetCDPAddr[6] =
>>> - ? ? ? ? ? ? ? ? ? ? ? { 0x01, 0x00, 0x0c, 0xcc, 0xcc, 0xcc };
>>> +uchar ? ? ? ? ?NetCDPAddr[6] = {
>>> + ? ? ? ? ? ? ? ? ? ? ? 0x01, 0x00, 0x0c, 0xcc, 0xcc, 0xcc };
>>> ...
>>
>> your fix here is worse than the original. ?just leave them be.
>
> Damn, you're right!
>
> I think a one-line solution would be even better (and much simpler):
>
> uchar ? ? ? ? ? NetCDPAddr[6] = {0x01, 0x00, 0x0c, 0xcc, 0xcc, 0xcc};
i agree
> BTW, this is the original checkpatch message:
> ?ERROR: that open brace { should be on the previous line
> ?#172: FILE: net.c:172:
> ?+uchar ? ? ? ? ?NetCDPAddr[6] =
> ?+ ? ? ? ? ? ? ? ? ? ? ? { 0x01, 0x00, 0x0c, 0xcc, 0xcc, 0xcc };
>
> So either we choose the one-line solution above, or we have the first
> checkpatch message that should be disabled in the U-Boot version, when it
> will exist.
sometimes it does warn when people do things wrongly, but this is once
again why i advocate people reviewing the output and not acting like a
robot.
i cant check checkpatch atm to see how it reacts, but these are
acceptable in my mind:
uchar foo[] = { 0, 1, 2, 3, };
uchar foo[] =
{ 0, 1, 2, 3, };
uchar foo[] = {
0, 1, 2, 3,
};
the form you used though is certainly wrong (even if checkpatch didnt say so):
uchar foo[] = {
0, 1, 2, 3, };
-mike
^ permalink raw reply [flat|nested] 32+ messages in thread
* [U-Boot] [PATCH 1/8] net/net.c: cosmetic: fix lines over 80 characters
2011-05-04 12:40 ` [U-Boot] [PATCH 1/8] net/net.c: cosmetic: fix lines over 80 characters Luca Ceresoli
@ 2011-05-09 19:42 ` Mike Frysinger
2011-05-10 7:13 ` Luca Ceresoli
0 siblings, 1 reply; 32+ messages in thread
From: Mike Frysinger @ 2011-05-09 19:42 UTC (permalink / raw)
To: u-boot
On Wednesday, May 04, 2011 08:40:40 Luca Ceresoli wrote:
> - debug("Got ICMP ECHO REQUEST, return %d bytes \n",
> - ETHER_HDR_SIZE + len);
> + debug("Got ICMP ECHO REQUEST, "
> + "return %d bytes \n",
> + ETHER_HDR_SIZE + len);
please do not split string literals
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20110509/05e385ce/attachment.pgp
^ permalink raw reply [flat|nested] 32+ messages in thread
* [U-Boot] [PATCH 1/8] net/net.c: cosmetic: fix lines over 80 characters
2011-05-09 19:42 ` Mike Frysinger
@ 2011-05-10 7:13 ` Luca Ceresoli
2011-05-10 15:51 ` Mike Frysinger
0 siblings, 1 reply; 32+ messages in thread
From: Luca Ceresoli @ 2011-05-10 7:13 UTC (permalink / raw)
To: u-boot
Hi Mike,
Mike Frysinger wrote:
> On Wednesday, May 04, 2011 08:40:40 Luca Ceresoli wrote:
>> - debug("Got ICMP ECHO REQUEST, return %d bytes \n",
>> - ETHER_HDR_SIZE + len);
>> + debug("Got ICMP ECHO REQUEST, "
>> + "return %d bytes \n",
>> + ETHER_HDR_SIZE + len);
> please do not split string literals
What do you suggest as an alternative? Leave the line more than
80 characters long?
I think the best thing would be to split the NetReceive() function that
contains that line, which is currently ~400 lines long. This would reduce
the amount of tabs in front of the deeply nested lines (such as this).
So I would agree to leave the line as is, waiting for NetReceive() to be
split in a future cleanup work.
Luca
^ permalink raw reply [flat|nested] 32+ messages in thread
* [U-Boot] [PATCH 1/8] net/net.c: cosmetic: fix lines over 80 characters
2011-05-10 7:13 ` Luca Ceresoli
@ 2011-05-10 15:51 ` Mike Frysinger
0 siblings, 0 replies; 32+ messages in thread
From: Mike Frysinger @ 2011-05-10 15:51 UTC (permalink / raw)
To: u-boot
On Tuesday, May 10, 2011 03:13:44 Luca Ceresoli wrote:
> Mike Frysinger wrote:
> > On Wednesday, May 04, 2011 08:40:40 Luca Ceresoli wrote:
> >> - debug("Got ICMP ECHO REQUEST, return %d bytes \n",
> >> - ETHER_HDR_SIZE + len);
> >> + debug("Got ICMP ECHO REQUEST, "
> >> + "return %d bytes \n",
> >> + ETHER_HDR_SIZE + len);
> >
> > please do not split string literals
>
> What do you suggest as an alternative? Leave the line more than
> 80 characters long?
if there is no alternative, then yes
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20110510/6cfd54d1/attachment.pgp
^ permalink raw reply [flat|nested] 32+ messages in thread
* [U-Boot] [PATCH v2 0/8] net/net.c: cleanups for checkpatch compliance
2011-05-04 12:40 [U-Boot] [PATCH 0/8] net/net.c: clenups for checkpatch compliance Luca Ceresoli
` (7 preceding siblings ...)
2011-05-04 12:40 ` [U-Boot] [PATCH 8/8] net/net.c: cosmetic: do not use assignment in if condition Luca Ceresoli
@ 2011-05-11 13:59 ` Luca Ceresoli
2011-05-11 13:59 ` [U-Boot] [PATCH v2 1/8] net/net.c: cosmetic: fix lines over 80 characters Luca Ceresoli
` (7 subsequent siblings)
16 siblings, 0 replies; 32+ messages in thread
From: Luca Ceresoli @ 2011-05-11 13:59 UTC (permalink / raw)
To: u-boot
Hi,
this is an update to the net/net.c cleanup, incorporating Mike's suggestions
to patches 1 and 2. Thanks Mike.
net/net.c currently raises a lot of checkpatch issues: 76 errors, 197 warnings.
This patchset fixes most of them, leaving 0 errors and 27 warnings.
Since the changes are quite massive I split them in separate patches, one
per each category of errors/warning.
The warnings that are still present are of the following types:
- WARNING: consider using kstrto* in preference to simple_strtoul
which is Linux-specific;
- WARNING: externs should be avoided in .c files
these are due to loop-dependencies between net/net.c and other files;
- WARNING: line over 80 characters
described in the commit message for patch 1;
- WARNING: Use of volatile is usually wrong [...]
I've had a quick look at these, but I don't know in detail how the
networking code and Ethernet drivers (and maybe DMA?) interact, so I cannot
remove them being sure that things will continue working.
Luca
Luca Ceresoli (8):
net/net.c: cosmetic: fix lines over 80 characters
net/net.c: cosmetic: variable initializations
net/net.c: cosmetic: fix whitespace issues
net/net.c: cosmetic: fix brace issues
net/net.c: cosmetic: fix pointer syntax issues
net/net.c: cosmetic: parentheses not required for return
net/net.c: cosmetic: fix indentation
net/net.c: cosmetic: do not use assignment in if condition
net/net.c | 593 ++++++++++++++++++++++++++++++++++---------------------------
1 files changed, 328 insertions(+), 265 deletions(-)
^ permalink raw reply [flat|nested] 32+ messages in thread
* [U-Boot] [PATCH v2 1/8] net/net.c: cosmetic: fix lines over 80 characters
2011-05-04 12:40 [U-Boot] [PATCH 0/8] net/net.c: clenups for checkpatch compliance Luca Ceresoli
` (8 preceding siblings ...)
2011-05-11 13:59 ` [U-Boot] [PATCH v2 0/8] net/net.c: cleanups for checkpatch compliance Luca Ceresoli
@ 2011-05-11 13:59 ` Luca Ceresoli
2011-05-12 20:14 ` Wolfgang Denk
2011-05-11 13:59 ` [U-Boot] [PATCH v2 2/8] net/net.c: cosmetic: variable initializations Luca Ceresoli
` (6 subsequent siblings)
16 siblings, 1 reply; 32+ messages in thread
From: Luca Ceresoli @ 2011-05-11 13:59 UTC (permalink / raw)
To: u-boot
This removes the following checkpatch warning:
- WARNING: line over 80 characters
There are three such warnings left.
The first is hard to fix with cosmetic-only changes without compromising code
readability, so I'm leaving it as it is for now:
WARNING: line over 80 characters
#1537: FILE: net.c:1537:
+ [4 tabs] memcpy(((Ethernet_t *)NetArpWaitTxPacket)->et_dest, ...
The other two cannot be fixed without splitting string literals, so it is
preferred to keep them longer than 80 characters.
Signed-off-by: Luca Ceresoli <luca.ceresoli@comelit.it>
Cc: Wolfgang Denk <wd@denx.de>
Cc: Ben Warren <biggerbadderben@gmail.com>
Cc: Mike Frysinger <vapier@gentoo.org>
---
Changes since v1:
- do not split string literals (even though this means leaving the line
longer than 80 characters).
net/net.c | 231 +++++++++++++++++++++++++++++++++++++++++--------------------
1 files changed, 155 insertions(+), 76 deletions(-)
diff --git a/net/net.c b/net/net.c
index e50bdf1..6e3af5b 100644
--- a/net/net.c
+++ b/net/net.c
@@ -101,7 +101,8 @@
DECLARE_GLOBAL_DATA_PTR;
#ifndef CONFIG_ARP_TIMEOUT
-# define ARP_TIMEOUT 5000UL /* Milliseconds before trying ARP again */
+/* Milliseconds before trying ARP again */
+# define ARP_TIMEOUT 5000UL
#else
# define ARP_TIMEOUT CONFIG_ARP_TIMEOUT
#endif
@@ -115,16 +116,24 @@ DECLARE_GLOBAL_DATA_PTR;
/** BOOTP EXTENTIONS **/
-IPaddr_t NetOurSubnetMask=0; /* Our subnet mask (0=unknown) */
-IPaddr_t NetOurGatewayIP=0; /* Our gateways IP address */
-IPaddr_t NetOurDNSIP=0; /* Our DNS IP address */
+/* Our subnet mask (0=unknown) */
+IPaddr_t NetOurSubnetMask=0;
+/* Our gateways IP address */
+IPaddr_t NetOurGatewayIP=0;
+/* Our DNS IP address */
+IPaddr_t NetOurDNSIP=0;
#if defined(CONFIG_BOOTP_DNS2)
-IPaddr_t NetOurDNS2IP=0; /* Our 2nd DNS IP address */
-#endif
-char NetOurNISDomain[32]={0,}; /* Our NIS domain */
-char NetOurHostName[32]={0,}; /* Our hostname */
-char NetOurRootPath[64]={0,}; /* Our bootpath */
-ushort NetBootFileSize=0; /* Our bootfile size in blocks */
+/* Our 2nd DNS IP address */
+IPaddr_t NetOurDNS2IP=0;
+#endif
+/* Our NIS domain */
+char NetOurNISDomain[32]={0,};
+/* Our hostname */
+char NetOurHostName[32]={0,};
+/* Our bootpath */
+char NetOurRootPath[64]={0,};
+/* Our bootfile size in blocks */
+ushort NetBootFileSize=0;
#ifdef CONFIG_MCAST_TFTP /* Multicast TFTP */
IPaddr_t Mcast_addr;
@@ -132,16 +141,25 @@ IPaddr_t Mcast_addr;
/** END OF BOOTP EXTENTIONS **/
-ulong NetBootFileXferSize; /* The actual transferred size of the bootfile (in bytes) */
-uchar NetOurEther[6]; /* Our ethernet address */
-uchar NetServerEther[6] = /* Boot server enet address */
+/* The actual transferred size of the bootfile (in bytes) */
+ulong NetBootFileXferSize;
+/* Our ethernet address */
+uchar NetOurEther[6];
+/* Boot server enet address */
+uchar NetServerEther[6] =
{ 0, 0, 0, 0, 0, 0 };
-IPaddr_t NetOurIP; /* Our IP addr (0 = unknown) */
-IPaddr_t NetServerIP; /* Server IP addr (0 = unknown) */
-volatile uchar *NetRxPacket; /* Current receive packet */
-int NetRxPacketLen; /* Current rx packet length */
-unsigned NetIPID; /* IP packet ID */
-uchar NetBcastAddr[6] = /* Ethernet bcast address */
+/* Our IP addr (0 = unknown) */
+IPaddr_t NetOurIP;
+/* Server IP addr (0 = unknown) */
+IPaddr_t NetServerIP;
+/* Current receive packet */
+volatile uchar *NetRxPacket;
+/* Current rx packet length */
+int NetRxPacketLen;
+/* IP packet ID */
+unsigned NetIPID;
+/* Ethernet bcast address */
+uchar NetBcastAddr[6] =
{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
uchar NetEtherNullAddr[6] =
{ 0, 0, 0, 0, 0, 0 };
@@ -149,24 +167,33 @@ uchar NetEtherNullAddr[6] =
void (*push_packet)(volatile void *, int len) = 0;
#endif
#if defined(CONFIG_CMD_CDP)
-uchar NetCDPAddr[6] = /* Ethernet bcast address */
+/* Ethernet bcast address */
+uchar NetCDPAddr[6] =
{ 0x01, 0x00, 0x0c, 0xcc, 0xcc, 0xcc };
#endif
-int NetState; /* Network loop state */
+/* Network loop state */
+int NetState;
#ifdef CONFIG_NET_MULTI
-int NetRestartWrap = 0; /* Tried all network devices */
-static int NetRestarted = 0; /* Network loop restarted */
-static int NetDevExists = 0; /* At least one device configured */
+/* Tried all network devices */
+int NetRestartWrap = 0;
+/* Network loop restarted */
+static int NetRestarted = 0;
+/* At least one device configured */
+static int NetDevExists = 0;
#endif
/* XXX in both little & big endian machines 0xFFFF == ntohs(-1) */
-ushort NetOurVLAN = 0xFFFF; /* default is without VLAN */
-ushort NetOurNativeVLAN = 0xFFFF; /* ditto */
+/* default is without VLAN */
+ushort NetOurVLAN = 0xFFFF;
+/* ditto */
+ushort NetOurNativeVLAN = 0xFFFF;
-char BootFile[128]; /* Boot File name */
+/* Boot File name */
+char BootFile[128];
#if defined(CONFIG_CMD_PING)
-IPaddr_t NetPingIP; /* the ip address to ping */
+/* the ip address to ping */
+IPaddr_t NetPingIP;
static void PingStart(void);
#endif
@@ -176,8 +203,10 @@ static void CDPStart(void);
#endif
#if defined(CONFIG_CMD_SNTP)
-IPaddr_t NetNtpServerIP; /* NTP server IP address */
-int NetTimeOffset=0; /* offset time from UTC */
+/* NTP server IP address */
+IPaddr_t NetNtpServerIP;
+/* offset time from UTC */
+int NetTimeOffset=0;
#endif
#ifdef CONFIG_NETCONSOLE
@@ -187,13 +216,19 @@ int nc_input_packet(uchar *pkt, unsigned dest, unsigned src, unsigned len);
volatile uchar PktBuf[(PKTBUFSRX+1) * PKTSIZE_ALIGN + PKTALIGN];
-volatile uchar *NetRxPackets[PKTBUFSRX]; /* Receive packets */
+/* Receive packet */
+volatile uchar *NetRxPackets[PKTBUFSRX];
-static rxhand_f *packetHandler; /* Current RX packet handler */
-static thand_f *timeHandler; /* Current timeout handler */
-static ulong timeStart; /* Time base value */
-static ulong timeDelta; /* Current timeout value */
-volatile uchar *NetTxPacket = 0; /* THE transmit packet */
+/* Current RX packet handler */
+static rxhand_f *packetHandler;
+/* Current timeout handler */
+static thand_f *timeHandler;
+/* Time base value */
+static ulong timeStart;
+/* Current timeout value */
+static ulong timeDelta;
+/* THE transmit packet */
+volatile uchar *NetTxPacket = 0;
static int net_check_prereq (proto_t protocol);
@@ -203,8 +238,10 @@ static int NetTryCount;
IPaddr_t NetArpWaitPacketIP;
IPaddr_t NetArpWaitReplyIP;
-uchar *NetArpWaitPacketMAC; /* MAC address of waiting packet's destination */
-uchar *NetArpWaitTxPacket; /* THE transmit packet */
+/* MAC address of waiting packet's destination */
+uchar *NetArpWaitPacketMAC;
+/* THE transmit packet */
+uchar *NetArpWaitTxPacket;
int NetArpWaitTxPacketSize;
uchar NetArpWaitPacketBuf[PKTSIZE_ALIGN + PKTALIGN];
ulong NetArpWaitTimerStart;
@@ -230,10 +267,13 @@ void ArpRequest (void)
arp->ar_pln = 4;
arp->ar_op = htons (ARPOP_REQUEST);
- memcpy (&arp->ar_data[0], NetOurEther, 6); /* source ET addr */
- NetWriteIP ((uchar *) & arp->ar_data[6], NetOurIP); /* source IP addr */
+ /* source ET addr */
+ memcpy (&arp->ar_data[0], NetOurEther, 6);
+ /* source IP addr */
+ NetWriteIP ((uchar *) & arp->ar_data[6], NetOurIP);
for (i = 10; i < 16; ++i) {
- arp->ar_data[i] = 0; /* dest ET addr = 0 */
+ /* dest ET addr = 0 */
+ arp->ar_data[i] = 0;
}
if ((NetArpWaitPacketIP & NetOurSubnetMask) !=
@@ -449,7 +489,9 @@ restart:
}
#if defined(CONFIG_MII) || defined(CONFIG_CMD_MII)
-#if defined(CONFIG_SYS_FAULT_ECHO_LINK_DOWN) && defined(CONFIG_STATUS_LED) && defined(STATUS_LED_RED)
+#if defined(CONFIG_SYS_FAULT_ECHO_LINK_DOWN) && \
+ defined(CONFIG_STATUS_LED) && \
+ defined(STATUS_LED_RED)
/*
* Echo the inverted link state to the fault LED.
*/
@@ -504,7 +546,8 @@ restart:
/*
* Echo the inverted link state to the fault LED.
*/
- if(miiphy_link(eth_get_dev()->name, CONFIG_SYS_FAULT_MII_ADDR)) {
+ if(miiphy_link(eth_get_dev()->name,
+ CONFIG_SYS_FAULT_MII_ADDR)) {
status_led_set (STATUS_LED_RED, STATUS_LED_OFF);
} else {
status_led_set (STATUS_LED_RED, STATUS_LED_ON);
@@ -654,7 +697,10 @@ NetSendUDPPacket(uchar *ether, IPaddr_t dest, int dport, int sport, int len)
if (dest == 0xFFFFFFFF)
ether = NetBcastAddr;
- /* if MAC address was not discovered yet, save the packet and do an ARP request */
+ /*
+ * if MAC address was not discovered yet, save the packet and do
+ * an ARP request
+ */
if (memcmp(ether, NetEtherNullAddr, 6) == 0) {
debug("sending ARP for %08lx\n", dest);
@@ -666,10 +712,12 @@ NetSendUDPPacket(uchar *ether, IPaddr_t dest, int dport, int sport, int len)
pkt += NetSetEther (pkt, NetArpWaitPacketMAC, PROT_IP);
NetSetIP (pkt, dest, dport, sport, len);
- memcpy(pkt + IP_HDR_SIZE, (uchar *)NetTxPacket + (pkt - (uchar *)NetArpWaitTxPacket) + IP_HDR_SIZE, len);
+ memcpy(pkt + IP_HDR_SIZE, (uchar *)NetTxPacket +
+ (pkt - (uchar *)NetArpWaitTxPacket) + IP_HDR_SIZE, len);
/* size of the waiting packet */
- NetArpWaitTxPacketSize = (pkt - NetArpWaitTxPacket) + IP_HDR_SIZE + len;
+ NetArpWaitTxPacketSize = (pkt - NetArpWaitTxPacket) +
+ IP_HDR_SIZE + len;
/* and do the ARP request */
NetArpWaitTry = 1;
@@ -713,9 +761,11 @@ int PingSend(void)
ip = (volatile IP_t *)pkt;
/*
- * Construct an IP and ICMP header. (need to set no fragment bit - XXX)
+ * Construct an IP and ICMP header.
+ * (need to set no fragment bit - XXX)
*/
- ip->ip_hl_v = 0x45; /* IP_HDR_SIZE / 4 (not including UDP) */
+ /* IP_HDR_SIZE / 4 (not including UDP) */
+ ip->ip_hl_v = 0x45;
ip->ip_tos = 0;
ip->ip_len = htons(IP_HDR_SIZE_NO_UDP + 8);
ip->ip_id = htons(NetIPID++);
@@ -723,8 +773,10 @@ int PingSend(void)
ip->ip_ttl = 255;
ip->ip_p = 0x01; /* ICMP */
ip->ip_sum = 0;
- NetCopyIP((void*)&ip->ip_src, &NetOurIP); /* already in network byte order */
- NetCopyIP((void*)&ip->ip_dst, &NetPingIP); /* - "" - */
+ /* already in network byte order */
+ NetCopyIP((void*)&ip->ip_src, &NetOurIP);
+ /* - "" - */
+ NetCopyIP((void*)&ip->ip_dst, &NetPingIP);
ip->ip_sum = ~NetCksum((uchar *)ip, IP_HDR_SIZE_NO_UDP / 2);
s = &ip->udp_src; /* XXX ICMP starts here */
@@ -735,7 +787,8 @@ int PingSend(void)
s[1] = ~NetCksum((uchar *)s, 8/2);
/* size of the waiting packet */
- NetArpWaitTxPacketSize = (pkt - NetArpWaitTxPacket) + IP_HDR_SIZE_NO_UDP + 8;
+ NetArpWaitTxPacketSize =
+ (pkt - NetArpWaitTxPacket) + IP_HDR_SIZE_NO_UDP + 8;
/* and do the ARP request */
NetArpWaitTry = 1;
@@ -800,7 +853,8 @@ static int CDPOK;
ushort CDPNativeVLAN;
ushort CDPApplianceVLAN;
-static const uchar CDP_SNAP_hdr[8] = { 0xAA, 0xAA, 0x03, 0x00, 0x00, 0x0C, 0x20, 0x00 };
+static const uchar CDP_SNAP_hdr[8] = { 0xAA, 0xAA, 0x03, 0x00, 0x00, 0x0C, 0x20,
+ 0x00 };
static ushort CDP_compute_csum(const uchar *buff, ushort len)
{
@@ -831,13 +885,15 @@ static ushort CDP_compute_csum(const uchar *buff, ushort len)
* CDP uses the IP checksum algorithm with a twist;
* for the last byte it *sign* extends and sums.
*/
- result = (result & 0xffff0000) | ((result + leftover) & 0x0000ffff);
+ result = (result & 0xffff0000) |
+ ((result + leftover) & 0x0000ffff);
}
while (result >> 16)
result = (result & 0xFFFF) + (result >> 16);
if (odd)
- result = ((result >> 8) & 0xff) | ((result & 0xff) << 8);
+ result = ((result >> 8) & 0xff) |
+ ((result & 0xff) << 8);
}
/* add up 16-bit and 17-bit words for 17+c bits */
@@ -890,7 +946,8 @@ int CDPSendTrigger(void)
*pkt++ = 180; /* TTL */
s = (volatile ushort *)pkt;
cp = s;
- *s++ = htons(0); /* checksum (0 for later calculation) */
+ /* checksum (0 for later calculation) */
+ *s++ = htons(0);
/* CDP fields */
#ifdef CONFIG_CDP_DEVICE_ID
@@ -962,7 +1019,8 @@ int CDPSendTrigger(void)
et->et_protlen = htons(len);
len = ETHER_HDR_SIZE + sizeof(CDP_SNAP_hdr);
- chksum = CDP_compute_csum((uchar *)NetTxPacket + len, (uchar *)s - (NetTxPacket + len));
+ chksum = CDP_compute_csum((uchar *)NetTxPacket + len,
+ (uchar *)s - (NetTxPacket + len));
if (chksum == 0)
chksum = 0xFFFF;
*cp = htons(chksum);
@@ -1019,7 +1077,10 @@ CDPHandler(const uchar * pkt, unsigned len)
if (pkt[0] < 0x02 || pkt[1] == 0)
return;
- /* if version is greater than 0x02 maybe we'll have a problem; output a warning */
+ /*
+ * if version is greater than 0x02 maybe we'll have a problem;
+ * output a warning
+ */
if (pkt[0] != 0x02)
printf("** WARNING: CDP packet received with a protocol version %d > 2\n",
pkt[0] & 0xff);
@@ -1075,10 +1136,12 @@ CDPHandler(const uchar * pkt, unsigned len)
ss = (const ushort *)(t + 1);
#ifdef CONFIG_CDP_APPLIANCE_VLAN_TYPE
- if (applid == CONFIG_CDP_APPLIANCE_VLAN_TYPE)
+ if (applid ==
+ CONFIG_CDP_APPLIANCE_VLAN_TYPE)
vlan = *ss;
#else
- vlan = ntohs(*ss); /* XXX will this work; dunno */
+ /* XXX will this work; dunno */
+ vlan = ntohs(*ss);
#endif
t += 3; tlen -= 3;
}
@@ -1440,7 +1503,8 @@ NetReceive(volatile uchar * inpkt, int len)
}
switch (ntohs(arp->ar_op)) {
- case ARPOP_REQUEST: /* reply with our IP address */
+ case ARPOP_REQUEST:
+ /* reply with our IP address */
debug("Got ARP REQUEST, return our IP\n");
pkt = (uchar *)et;
pkt += NetSetEther(pkt, et->et_src, PROT_ARP);
@@ -1449,7 +1513,8 @@ NetReceive(volatile uchar * inpkt, int len)
NetCopyIP(&arp->ar_data[16], &arp->ar_data[6]);
memcpy (&arp->ar_data[ 0], NetOurEther, 6);
NetCopyIP(&arp->ar_data[ 6], &NetOurIP);
- (void) eth_send((uchar *)et, (pkt - (uchar *)et) + ARP_HDR_SIZE);
+ (void) eth_send((uchar *)et,
+ (pkt - (uchar *)et) + ARP_HDR_SIZE);
return;
case ARPOP_REPLY: /* arp reply */
@@ -1474,14 +1539,16 @@ NetReceive(volatile uchar * inpkt, int len)
if (tmp == NetArpWaitReplyIP) {
debug("Got it\n");
/* save address for later use */
- memcpy(NetArpWaitPacketMAC, &arp->ar_data[0], 6);
+ memcpy(NetArpWaitPacketMAC,
+ &arp->ar_data[0], 6);
#ifdef CONFIG_NETCONSOLE
(*packetHandler)(0,0,0,0);
#endif
/* modify header, and transmit it */
memcpy(((Ethernet_t *)NetArpWaitTxPacket)->et_dest, NetArpWaitPacketMAC, 6);
- (void) eth_send(NetArpWaitTxPacket, NetArpWaitTxPacketSize);
+ (void) eth_send(NetArpWaitTxPacket,
+ NetArpWaitTxPacketSize);
/* no arp request pending now */
NetArpWaitPacketIP = 0;
@@ -1491,7 +1558,8 @@ NetReceive(volatile uchar * inpkt, int len)
}
return;
default:
- debug("Unexpected ARP opcode 0x%x\n", ntohs(arp->ar_op));
+ debug("Unexpected ARP opcode 0x%x\n",
+ ntohs(arp->ar_op));
return;
}
break;
@@ -1588,19 +1656,21 @@ NetReceive(volatile uchar * inpkt, int len)
case ICMP_REDIRECT:
if (icmph->code != ICMP_REDIR_HOST)
return;
- printf (" ICMP Host Redirect to %pI4 ", &icmph->un.gateway);
+ printf (" ICMP Host Redirect to %pI4 ",
+ &icmph->un.gateway);
return;
#if defined(CONFIG_CMD_PING)
case ICMP_ECHO_REPLY:
/*
- * IP header OK. Pass the packet to the current handler.
+ * IP header OK. Pass the packet to the
+ * current handler.
*/
/* XXX point to ip packet */
(*packetHandler)((uchar *)ip, 0, 0, 0);
return;
case ICMP_ECHO_REQUEST:
debug("Got ICMP ECHO REQUEST, return %d bytes \n",
- ETHER_HDR_SIZE + len);
+ ETHER_HDR_SIZE + len);
memcpy (&et->et_dest[0], &et->et_src[0], 6);
memcpy (&et->et_src[ 0], NetOurEther, 6);
@@ -1609,13 +1679,15 @@ NetReceive(volatile uchar * inpkt, int len)
ip->ip_off = 0;
NetCopyIP((void*)&ip->ip_dst, &ip->ip_src);
NetCopyIP((void*)&ip->ip_src, &NetOurIP);
- ip->ip_sum = ~NetCksum((uchar *)ip, IP_HDR_SIZE_NO_UDP >> 1);
+ ip->ip_sum = ~NetCksum((uchar *)ip,
+ IP_HDR_SIZE_NO_UDP >> 1);
icmph->type = ICMP_ECHO_REPLY;
icmph->checksum = 0;
icmph->checksum = ~NetCksum((uchar *)icmph,
- (len - IP_HDR_SIZE_NO_UDP) >> 1);
- (void) eth_send((uchar *)et, ETHER_HDR_SIZE + len);
+ (len - IP_HDR_SIZE_NO_UDP) >> 1);
+ (void) eth_send((uchar *)et,
+ ETHER_HDR_SIZE + len);
return;
#endif
default:
@@ -1656,7 +1728,8 @@ NetReceive(volatile uchar * inpkt, int len)
xsum += sumdata;
}
while ((xsum >> 16) != 0) {
- xsum = (xsum & 0x0000ffff) + ((xsum >> 16) & 0x0000ffff);
+ xsum = (xsum & 0x0000ffff) +
+ ((xsum >> 16) & 0x0000ffff);
}
if ((xsum != 0x00000000) && (xsum != 0x0000ffff)) {
printf(" UDP wrong checksum %08lx %08x\n",
@@ -1804,7 +1877,8 @@ NetEthHdrSize(void)
if (myvlanid == (ushort)-1)
myvlanid = VLAN_NONE;
- return ((myvlanid & VLAN_IDMASK) == VLAN_NONE) ? ETHER_HDR_SIZE : VLAN_ETHER_HDR_SIZE;
+ return ((myvlanid & VLAN_IDMASK) == VLAN_NONE) ? ETHER_HDR_SIZE :
+ VLAN_ETHER_HDR_SIZE;
}
int
@@ -1849,7 +1923,8 @@ NetSetIP(volatile uchar * xip, IPaddr_t dest, int dport, int sport, int len)
* Construct an IP and UDP header.
* (need to set no fragment bit - XXX)
*/
- ip->ip_hl_v = 0x45; /* IP_HDR_SIZE / 4 (not including UDP) */
+ /* IP_HDR_SIZE / 4 (not including UDP) */
+ ip->ip_hl_v = 0x45;
ip->ip_tos = 0;
ip->ip_len = htons(IP_HDR_SIZE + len);
ip->ip_id = htons(NetIPID++);
@@ -1857,8 +1932,10 @@ NetSetIP(volatile uchar * xip, IPaddr_t dest, int dport, int sport, int len)
ip->ip_ttl = 255;
ip->ip_p = 17; /* UDP */
ip->ip_sum = 0;
- NetCopyIP((void*)&ip->ip_src, &NetOurIP); /* already in network byte order */
- NetCopyIP((void*)&ip->ip_dst, &dest); /* - "" - */
+ /* already in network byte order */
+ NetCopyIP((void*)&ip->ip_src, &NetOurIP);
+ /* - "" - */
+ NetCopyIP((void*)&ip->ip_dst, &dest);
ip->udp_src = htons(sport);
ip->udp_dst = htons(dport);
ip->udp_len = htons(8 + len);
@@ -1879,7 +1956,9 @@ void copy_filename (char *dst, const char *src, int size)
*dst = '\0';
}
-#if defined(CONFIG_CMD_NFS) || defined(CONFIG_CMD_SNTP) || defined(CONFIG_CMD_DNS)
+#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
--
1.7.1
^ permalink raw reply related [flat|nested] 32+ messages in thread
* [U-Boot] [PATCH v2 2/8] net/net.c: cosmetic: variable initializations
2011-05-04 12:40 [U-Boot] [PATCH 0/8] net/net.c: clenups for checkpatch compliance Luca Ceresoli
` (9 preceding siblings ...)
2011-05-11 13:59 ` [U-Boot] [PATCH v2 1/8] net/net.c: cosmetic: fix lines over 80 characters Luca Ceresoli
@ 2011-05-11 13:59 ` Luca Ceresoli
2011-05-12 20:17 ` Wolfgang Denk
2011-05-11 13:59 ` [U-Boot] [PATCH v2 3/8] net/net.c: cosmetic: fix whitespace issues Luca Ceresoli
` (5 subsequent siblings)
16 siblings, 1 reply; 32+ messages in thread
From: Luca Ceresoli @ 2011-05-11 13:59 UTC (permalink / raw)
To: u-boot
This removes the following checkpatch errors:
- ERROR: do not initialise globals to 0 or NULL
- ERROR: spaces required around that '=' (ctx:VxV)
- ERROR: that open brace { should be on the previous line
Signed-off-by: Luca Ceresoli <luca.ceresoli@comelit.it>
Cc: Wolfgang Denk <wd@denx.de>
Cc: Ben Warren <biggerbadderben@gmail.com>
Cc: Mike Frysinger <vapier@gentoo.org>
---
Changes since v1:
- re-fix array initializations (the fix in v1 was worse than the original).
net/net.c | 40 ++++++++++++++++++----------------------
1 files changed, 18 insertions(+), 22 deletions(-)
diff --git a/net/net.c b/net/net.c
index 6e3af5b..4715699 100644
--- a/net/net.c
+++ b/net/net.c
@@ -117,23 +117,23 @@ DECLARE_GLOBAL_DATA_PTR;
/** BOOTP EXTENTIONS **/
/* Our subnet mask (0=unknown) */
-IPaddr_t NetOurSubnetMask=0;
+IPaddr_t NetOurSubnetMask;
/* Our gateways IP address */
-IPaddr_t NetOurGatewayIP=0;
+IPaddr_t NetOurGatewayIP;
/* Our DNS IP address */
-IPaddr_t NetOurDNSIP=0;
+IPaddr_t NetOurDNSIP;
#if defined(CONFIG_BOOTP_DNS2)
/* Our 2nd DNS IP address */
-IPaddr_t NetOurDNS2IP=0;
+IPaddr_t NetOurDNS2IP;
#endif
/* Our NIS domain */
-char NetOurNISDomain[32]={0,};
+char NetOurNISDomain[32] = {0,};
/* Our hostname */
-char NetOurHostName[32]={0,};
+char NetOurHostName[32] = {0,};
/* Our bootpath */
-char NetOurRootPath[64]={0,};
+char NetOurRootPath[64] = {0,};
/* Our bootfile size in blocks */
-ushort NetBootFileSize=0;
+ushort NetBootFileSize;
#ifdef CONFIG_MCAST_TFTP /* Multicast TFTP */
IPaddr_t Mcast_addr;
@@ -146,8 +146,7 @@ ulong NetBootFileXferSize;
/* Our ethernet address */
uchar NetOurEther[6];
/* Boot server enet address */
-uchar NetServerEther[6] =
- { 0, 0, 0, 0, 0, 0 };
+uchar NetServerEther[6];
/* Our IP addr (0 = unknown) */
IPaddr_t NetOurIP;
/* Server IP addr (0 = unknown) */
@@ -159,27 +158,24 @@ int NetRxPacketLen;
/* IP packet ID */
unsigned NetIPID;
/* Ethernet bcast address */
-uchar NetBcastAddr[6] =
- { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
-uchar NetEtherNullAddr[6] =
- { 0, 0, 0, 0, 0, 0 };
+uchar NetBcastAddr[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
+uchar NetEtherNullAddr[6];
#ifdef CONFIG_API
void (*push_packet)(volatile void *, int len) = 0;
#endif
#if defined(CONFIG_CMD_CDP)
/* Ethernet bcast address */
-uchar NetCDPAddr[6] =
- { 0x01, 0x00, 0x0c, 0xcc, 0xcc, 0xcc };
+uchar NetCDPAddr[6] = { 0x01, 0x00, 0x0c, 0xcc, 0xcc, 0xcc };
#endif
/* Network loop state */
int NetState;
#ifdef CONFIG_NET_MULTI
/* Tried all network devices */
-int NetRestartWrap = 0;
+int NetRestartWrap;
/* Network loop restarted */
-static int NetRestarted = 0;
+static int NetRestarted;
/* At least one device configured */
-static int NetDevExists = 0;
+static int NetDevExists;
#endif
/* XXX in both little & big endian machines 0xFFFF == ntohs(-1) */
@@ -206,7 +202,7 @@ static void CDPStart(void);
/* NTP server IP address */
IPaddr_t NetNtpServerIP;
/* offset time from UTC */
-int NetTimeOffset=0;
+int NetTimeOffset;
#endif
#ifdef CONFIG_NETCONSOLE
@@ -228,7 +224,7 @@ static ulong timeStart;
/* Current timeout value */
static ulong timeDelta;
/* THE transmit packet */
-volatile uchar *NetTxPacket = 0;
+volatile uchar *NetTxPacket;
static int net_check_prereq (proto_t protocol);
@@ -319,7 +315,7 @@ void ArpTimeoutCheck(void)
static void
NetInitLoop(proto_t protocol)
{
- static int env_changed_id = 0;
+ static int env_changed_id;
bd_t *bd = gd->bd;
int env_id = get_env_id ();
--
1.7.1
^ permalink raw reply related [flat|nested] 32+ messages in thread
* [U-Boot] [PATCH v2 3/8] net/net.c: cosmetic: fix whitespace issues
2011-05-04 12:40 [U-Boot] [PATCH 0/8] net/net.c: clenups for checkpatch compliance Luca Ceresoli
` (10 preceding siblings ...)
2011-05-11 13:59 ` [U-Boot] [PATCH v2 2/8] net/net.c: cosmetic: variable initializations Luca Ceresoli
@ 2011-05-11 13:59 ` Luca Ceresoli
2011-05-12 20:17 ` Wolfgang Denk
2011-05-11 13:59 ` [U-Boot] [PATCH v2 4/8] net/net.c: cosmetic: fix brace issues Luca Ceresoli
` (4 subsequent siblings)
16 siblings, 1 reply; 32+ messages in thread
From: Luca Ceresoli @ 2011-05-11 13:59 UTC (permalink / raw)
To: u-boot
This removes the following checkpatch issues:
- ERROR: space prohibited after that open parenthesis '('
- ERROR: space prohibited before that close parenthesis ')'
- ERROR: space prohibited after that open square bracket '['
- ERROR: space prohibited after that '&' (ctx:WxW)
- ERROR: spaces required around that '=' (ctx:VxW)
- ERROR: space required before the open parenthesis '('
- ERROR: space required after that ',' (ctx:VxV)
- ERROR: need consistent spacing around '+' (ctx:WxV)
- WARNING: unnecessary whitespace before a quoted newline
- WARNING: please, no spaces at the start of a line
- WARNING: space prohibited between function name and open
parenthesis '('
Signed-off-by: Luca Ceresoli <luca.ceresoli@comelit.it>
Cc: Wolfgang Denk <wd@denx.de>
Cc: Ben Warren <biggerbadderben@gmail.com>
Cc: Mike Frysinger <vapier@gentoo.org>
---
Changes since v1: none.
net/net.c | 192 ++++++++++++++++++++++++++++++------------------------------
1 files changed, 96 insertions(+), 96 deletions(-)
diff --git a/net/net.c b/net/net.c
index 4715699..172f4d5 100644
--- a/net/net.c
+++ b/net/net.c
@@ -226,7 +226,7 @@ static ulong timeDelta;
/* THE transmit packet */
volatile uchar *NetTxPacket;
-static int net_check_prereq (proto_t protocol);
+static int net_check_prereq(proto_t protocol);
static int NetTryCount;
@@ -243,7 +243,7 @@ uchar NetArpWaitPacketBuf[PKTSIZE_ALIGN + PKTALIGN];
ulong NetArpWaitTimerStart;
int NetArpWaitTry;
-void ArpRequest (void)
+void ArpRequest(void)
{
int i;
volatile uchar *pkt;
@@ -253,20 +253,20 @@ void ArpRequest (void)
pkt = NetTxPacket;
- pkt += NetSetEther (pkt, NetBcastAddr, PROT_ARP);
+ pkt += NetSetEther(pkt, NetBcastAddr, PROT_ARP);
arp = (ARP_t *) pkt;
- arp->ar_hrd = htons (ARP_ETHER);
- arp->ar_pro = htons (PROT_IP);
+ arp->ar_hrd = htons(ARP_ETHER);
+ arp->ar_pro = htons(PROT_IP);
arp->ar_hln = 6;
arp->ar_pln = 4;
- arp->ar_op = htons (ARPOP_REQUEST);
+ arp->ar_op = htons(ARPOP_REQUEST);
/* source ET addr */
- memcpy (&arp->ar_data[0], NetOurEther, 6);
+ memcpy(&arp->ar_data[0], NetOurEther, 6);
/* source IP addr */
- NetWriteIP ((uchar *) & arp->ar_data[6], NetOurIP);
+ NetWriteIP((uchar *) &arp->ar_data[6], NetOurIP);
for (i = 10; i < 16; ++i) {
/* dest ET addr = 0 */
arp->ar_data[i] = 0;
@@ -275,7 +275,7 @@ void ArpRequest (void)
if ((NetArpWaitPacketIP & NetOurSubnetMask) !=
(NetOurIP & NetOurSubnetMask)) {
if (NetOurGatewayIP == 0) {
- puts ("## Warning: gatewayip needed but not set\n");
+ puts("## Warning: gatewayip needed but not set\n");
NetArpWaitReplyIP = NetArpWaitPacketIP;
} else {
NetArpWaitReplyIP = NetOurGatewayIP;
@@ -284,8 +284,8 @@ void ArpRequest (void)
NetArpWaitReplyIP = NetArpWaitPacketIP;
}
- NetWriteIP ((uchar *) & arp->ar_data[16], NetArpWaitReplyIP);
- (void) eth_send (NetTxPacket, (pkt - NetTxPacket) + ARP_HDR_SIZE);
+ NetWriteIP((uchar *) &arp->ar_data[16], NetArpWaitReplyIP);
+ (void) eth_send(NetTxPacket, (pkt - NetTxPacket) + ARP_HDR_SIZE);
}
void ArpTimeoutCheck(void)
@@ -302,7 +302,7 @@ void ArpTimeoutCheck(void)
NetArpWaitTry++;
if (NetArpWaitTry >= ARP_TIMEOUT_COUNT) {
- puts ("\nARP Retry count exceeded; starting again\n");
+ puts("\nARP Retry count exceeded; starting again\n");
NetArpWaitTry = 0;
NetStartAgain();
} else {
@@ -317,14 +317,14 @@ NetInitLoop(proto_t protocol)
{
static int env_changed_id;
bd_t *bd = gd->bd;
- int env_id = get_env_id ();
+ int env_id = get_env_id();
/* update only when the environment has changed */
if (env_changed_id != env_id) {
NetCopyIP(&NetOurIP, &bd->bi_ip_addr);
- NetOurGatewayIP = getenv_IPaddr ("gatewayip");
- NetOurSubnetMask= getenv_IPaddr ("netmask");
- NetServerIP = getenv_IPaddr ("serverip");
+ NetOurGatewayIP = getenv_IPaddr("gatewayip");
+ NetOurSubnetMask = getenv_IPaddr("netmask");
+ NetServerIP = getenv_IPaddr("serverip");
NetOurNativeVLAN = getenv_VLAN("nvlan");
NetOurVLAN = getenv_VLAN("vlan");
#if defined(CONFIG_CMD_DNS)
@@ -389,7 +389,7 @@ NetLoop(proto_t protocol)
restart:
#ifdef CONFIG_NET_MULTI
- memcpy (NetOurEther, eth_get_dev()->enetaddr, 6);
+ memcpy(NetOurEther, eth_get_dev()->enetaddr, 6);
#else
eth_getenv_enetaddr("ethaddr", NetOurEther);
#endif
@@ -403,7 +403,7 @@ restart:
*/
NetInitLoop(protocol);
- switch (net_check_prereq (protocol)) {
+ switch (net_check_prereq(protocol)) {
case 1:
/* network not configured */
eth_halt();
@@ -436,14 +436,14 @@ restart:
case BOOTP:
BootpTry = 0;
NetOurIP = 0;
- BootpRequest ();
+ BootpRequest();
break;
#if defined(CONFIG_CMD_RARP)
case RARP:
RarpTry = 0;
NetOurIP = 0;
- RarpRequest ();
+ RarpRequest();
break;
#endif
#if defined(CONFIG_CMD_PING)
@@ -491,10 +491,10 @@ restart:
/*
* Echo the inverted link state to the fault LED.
*/
- if(miiphy_link(eth_get_dev()->name, CONFIG_SYS_FAULT_MII_ADDR)) {
- status_led_set (STATUS_LED_RED, STATUS_LED_OFF);
+ if (miiphy_link(eth_get_dev()->name, CONFIG_SYS_FAULT_MII_ADDR)) {
+ status_led_set(STATUS_LED_RED, STATUS_LED_OFF);
} else {
- status_led_set (STATUS_LED_RED, STATUS_LED_ON);
+ status_led_set(STATUS_LED_RED, STATUS_LED_ON);
}
#endif /* CONFIG_SYS_FAULT_ECHO_LINK_DOWN, ... */
#endif /* CONFIG_MII, ... */
@@ -522,7 +522,7 @@ restart:
*/
if (ctrlc()) {
eth_halt();
- puts ("\nAbort\n");
+ puts("\nAbort\n");
return (-1);
}
@@ -536,19 +536,19 @@ restart:
thand_f *x;
#if defined(CONFIG_MII) || defined(CONFIG_CMD_MII)
-# if defined(CONFIG_SYS_FAULT_ECHO_LINK_DOWN) && \
- defined(CONFIG_STATUS_LED) && \
- defined(STATUS_LED_RED)
+#if defined(CONFIG_SYS_FAULT_ECHO_LINK_DOWN) && \
+ defined(CONFIG_STATUS_LED) && \
+ defined(STATUS_LED_RED)
/*
* Echo the inverted link state to the fault LED.
*/
- if(miiphy_link(eth_get_dev()->name,
+ if (miiphy_link(eth_get_dev()->name,
CONFIG_SYS_FAULT_MII_ADDR)) {
- status_led_set (STATUS_LED_RED, STATUS_LED_OFF);
+ status_led_set(STATUS_LED_RED, STATUS_LED_OFF);
} else {
- status_led_set (STATUS_LED_RED, STATUS_LED_ON);
+ status_led_set(STATUS_LED_RED, STATUS_LED_ON);
}
-# endif /* CONFIG_SYS_FAULT_ECHO_LINK_DOWN, ... */
+#endif /* CONFIG_SYS_FAULT_ECHO_LINK_DOWN, ... */
#endif /* CONFIG_MII, ... */
x = timeHandler;
timeHandler = (thand_f *)0;
@@ -599,7 +599,7 @@ startAgainHandler(uchar * pkt, unsigned dest, unsigned src, unsigned len)
/* Totally ignore the packet */
}
-void NetStartAgain (void)
+void NetStartAgain(void)
{
char *nretry;
int retry_forever = 0;
@@ -627,19 +627,19 @@ void NetStartAgain (void)
NetTryCount++;
#ifndef CONFIG_NET_MULTI
- NetSetTimeout (10000UL, startAgainTimeout);
- NetSetHandler (startAgainHandler);
+ NetSetTimeout(10000UL, startAgainTimeout);
+ NetSetHandler(startAgainHandler);
#else /* !CONFIG_NET_MULTI*/
- eth_halt ();
+ eth_halt();
#if !defined(CONFIG_NET_DO_NOT_TRY_ANOTHER)
- eth_try_another (!NetRestarted);
+ eth_try_another(!NetRestarted);
#endif
- eth_init (gd->bd);
+ eth_init(gd->bd);
if (NetRestartWrap) {
NetRestartWrap = 0;
if (NetDevExists) {
- NetSetTimeout (10000UL, startAgainTimeout);
- NetSetHandler (startAgainHandler);
+ NetSetTimeout(10000UL, startAgainTimeout);
+ NetSetHandler(startAgainHandler);
} else {
NetState = NETLOOP_FAIL;
}
@@ -705,9 +705,9 @@ NetSendUDPPacket(uchar *ether, IPaddr_t dest, int dport, int sport, int len)
NetArpWaitPacketMAC = ether;
pkt = NetArpWaitTxPacket;
- pkt += NetSetEther (pkt, NetArpWaitPacketMAC, PROT_IP);
+ pkt += NetSetEther(pkt, NetArpWaitPacketMAC, PROT_IP);
- NetSetIP (pkt, dest, dport, sport, len);
+ NetSetIP(pkt, dest, dport, sport, len);
memcpy(pkt + IP_HDR_SIZE, (uchar *)NetTxPacket +
(pkt - (uchar *)NetArpWaitTxPacket) + IP_HDR_SIZE, len);
@@ -725,8 +725,8 @@ NetSendUDPPacket(uchar *ether, IPaddr_t dest, int dport, int sport, int len)
debug("sending UDP to %08lx/%pM\n", dest, ether);
pkt = (uchar *)NetTxPacket;
- pkt += NetSetEther (pkt, ether, PROT_IP);
- NetSetIP (pkt, dest, dport, sport, len);
+ pkt += NetSetEther(pkt, ether, PROT_IP);
+ NetSetIP(pkt, dest, dport, sport, len);
(void) eth_send(NetTxPacket, (pkt - NetTxPacket) + IP_HDR_SIZE + len);
return 0; /* transmitted */
@@ -794,14 +794,14 @@ int PingSend(void)
}
static void
-PingTimeout (void)
+PingTimeout(void)
{
eth_halt();
NetState = NETLOOP_FAIL; /* we did not get the reply */
}
static void
-PingHandler (uchar * pkt, unsigned dest, unsigned src, unsigned len)
+PingHandler(uchar * pkt, unsigned dest, unsigned src, unsigned len)
{
IPaddr_t tmp;
volatile IP_t *ip = (volatile IP_t *)pkt;
@@ -816,10 +816,10 @@ PingHandler (uchar * pkt, unsigned dest, unsigned src, unsigned len)
static void PingStart(void)
{
#if defined(CONFIG_NET_MULTI)
- printf ("Using %s device\n", eth_get_name());
+ printf("Using %s device\n", eth_get_name());
#endif /* CONFIG_NET_MULTI */
- NetSetTimeout (10000UL, PingTimeout);
- NetSetHandler (PingHandler);
+ NetSetTimeout(10000UL, PingTimeout);
+ NetSetHandler(PingHandler);
PingSend();
}
@@ -917,8 +917,8 @@ int CDPSendTrigger(void)
Ethernet_t *et;
int len;
ushort chksum;
-#if defined(CONFIG_CDP_DEVICE_ID) || defined(CONFIG_CDP_PORT_ID) || \
- defined(CONFIG_CDP_VERSION) || defined(CONFIG_CDP_PLATFORM)
+#if defined(CONFIG_CDP_DEVICE_ID) || defined(CONFIG_CDP_PORT_ID) || \
+ defined(CONFIG_CDP_VERSION) || defined(CONFIG_CDP_PLATFORM)
char buf[32];
#endif
@@ -1026,12 +1026,12 @@ int CDPSendTrigger(void)
}
static void
-CDPTimeout (void)
+CDPTimeout(void)
{
CDPSeq++;
if (CDPSeq < 3) {
- NetSetTimeout (CDP_TIMEOUT, CDPTimeout);
+ NetSetTimeout(CDP_TIMEOUT, CDPTimeout);
CDPSendTrigger();
return;
}
@@ -1044,7 +1044,7 @@ CDPTimeout (void)
}
static void
-CDPDummyHandler (uchar * pkt, unsigned dest, unsigned src, unsigned len)
+CDPDummyHandler(uchar * pkt, unsigned dest, unsigned src, unsigned len)
{
/* nothing */
}
@@ -1169,7 +1169,7 @@ CDPHandler(const uchar * pkt, unsigned len)
static void CDPStart(void)
{
#if defined(CONFIG_NET_MULTI)
- printf ("Using %s device\n", eth_get_name());
+ printf("Using %s device\n", eth_get_name());
#endif
CDPSeq = 0;
CDPOK = 0;
@@ -1177,8 +1177,8 @@ static void CDPStart(void)
CDPNativeVLAN = htons(-1);
CDPApplianceVLAN = htons(-1);
- NetSetTimeout (CDP_TIMEOUT, CDPTimeout);
- NetSetHandler (CDPDummyHandler);
+ NetSetTimeout(CDP_TIMEOUT, CDPTimeout);
+ NetSetHandler(CDPDummyHandler);
CDPSendTrigger();
}
@@ -1282,7 +1282,7 @@ static IP_t *__NetDefragment(IP_t *ip, int *lenp)
* (thus being a superset of a previously-received fragment).
*/
- if ( (h >= thisfrag) && (h->last_byte <= start + len) ) {
+ if ((h >= thisfrag) && (h->last_byte <= start + len)) {
/* complete overlap with hole: remove hole */
if (!h->prev_hole && !h->next_hole) {
/* last remaining hole */
@@ -1505,10 +1505,10 @@ NetReceive(volatile uchar * inpkt, int len)
pkt = (uchar *)et;
pkt += NetSetEther(pkt, et->et_src, PROT_ARP);
arp->ar_op = htons(ARPOP_REPLY);
- memcpy (&arp->ar_data[10], &arp->ar_data[0], 6);
+ memcpy(&arp->ar_data[10], &arp->ar_data[0], 6);
NetCopyIP(&arp->ar_data[16], &arp->ar_data[6]);
- memcpy (&arp->ar_data[ 0], NetOurEther, 6);
- NetCopyIP(&arp->ar_data[ 6], &NetOurIP);
+ memcpy(&arp->ar_data[0], NetOurEther, 6);
+ NetCopyIP(&arp->ar_data[6], &NetOurIP);
(void) eth_send((uchar *)et,
(pkt - (uchar *)et) + ARP_HDR_SIZE);
return;
@@ -1539,7 +1539,7 @@ NetReceive(volatile uchar * inpkt, int len)
&arp->ar_data[0], 6);
#ifdef CONFIG_NETCONSOLE
- (*packetHandler)(0,0,0,0);
+ (*packetHandler)(0, 0, 0, 0);
#endif
/* modify header, and transmit it */
memcpy(((Ethernet_t *)NetArpWaitTxPacket)->et_dest, NetArpWaitPacketMAC, 6);
@@ -1574,14 +1574,14 @@ NetReceive(volatile uchar * inpkt, int len)
(ntohs(arp->ar_pro) != PROT_IP) ||
(arp->ar_hln != 6) || (arp->ar_pln != 4)) {
- puts ("invalid RARP header\n");
+ puts("invalid RARP header\n");
} else {
NetCopyIP(&NetOurIP, &arp->ar_data[16]);
if (NetServerIP == 0)
- NetCopyIP(&NetServerIP, &arp->ar_data[ 6]);
- memcpy (NetServerEther, &arp->ar_data[ 0], 6);
+ NetCopyIP(&NetServerIP, &arp->ar_data[6]);
+ memcpy(NetServerEther, &arp->ar_data[0], 6);
- (*packetHandler)(0,0,0,0);
+ (*packetHandler)(0, 0, 0, 0);
}
break;
#endif
@@ -1610,7 +1610,7 @@ NetReceive(volatile uchar * inpkt, int len)
}
/* Check the Checksum of the header */
if (!NetCksumOk((uchar *)ip, IP_HDR_SIZE_NO_UDP / 2)) {
- puts ("checksum bad\n");
+ puts("checksum bad\n");
return;
}
/* If it is not for us, ignore it */
@@ -1652,7 +1652,7 @@ NetReceive(volatile uchar * inpkt, int len)
case ICMP_REDIRECT:
if (icmph->code != ICMP_REDIR_HOST)
return;
- printf (" ICMP Host Redirect to %pI4 ",
+ printf(" ICMP Host Redirect to %pI4 ",
&icmph->un.gateway);
return;
#if defined(CONFIG_CMD_PING)
@@ -1665,11 +1665,11 @@ NetReceive(volatile uchar * inpkt, int len)
(*packetHandler)((uchar *)ip, 0, 0, 0);
return;
case ICMP_ECHO_REQUEST:
- debug("Got ICMP ECHO REQUEST, return %d bytes \n",
+ debug("Got ICMP ECHO REQUEST, return %d bytes\n",
ETHER_HDR_SIZE + len);
- memcpy (&et->et_dest[0], &et->et_src[0], 6);
- memcpy (&et->et_src[ 0], NetOurEther, 6);
+ memcpy(&et->et_dest[0], &et->et_src[0], 6);
+ memcpy(&et->et_src[0], NetOurEther, 6);
ip->ip_sum = 0;
ip->ip_off = 0;
@@ -1737,7 +1737,7 @@ NetReceive(volatile uchar * inpkt, int len)
#ifdef CONFIG_NETCONSOLE
- nc_input_packet((uchar *)ip +IP_HDR_SIZE,
+ nc_input_packet((uchar *)ip + IP_HDR_SIZE,
ntohs(ip->udp_dst),
ntohs(ip->udp_src),
ntohs(ip->udp_len) - 8);
@@ -1745,7 +1745,7 @@ NetReceive(volatile uchar * inpkt, int len)
/*
* IP header OK. Pass the packet to the current handler.
*/
- (*packetHandler)((uchar *)ip +IP_HDR_SIZE,
+ (*packetHandler)((uchar *)ip + IP_HDR_SIZE,
ntohs(ip->udp_dst),
ntohs(ip->udp_src),
ntohs(ip->udp_len) - 8);
@@ -1756,14 +1756,14 @@ NetReceive(volatile uchar * inpkt, int len)
/**********************************************************************/
-static int net_check_prereq (proto_t protocol)
+static int net_check_prereq(proto_t protocol)
{
switch (protocol) {
/* Fall through */
#if defined(CONFIG_CMD_PING)
case PING:
if (NetPingIP == 0) {
- puts ("*** ERROR: ping address not given\n");
+ puts("*** ERROR: ping address not given\n");
return (1);
}
goto common;
@@ -1771,7 +1771,7 @@ static int net_check_prereq (proto_t protocol)
#if defined(CONFIG_CMD_SNTP)
case SNTP:
if (NetNtpServerIP == 0) {
- puts ("*** ERROR: NTP server address not given\n");
+ puts("*** ERROR: NTP server address not given\n");
return (1);
}
goto common;
@@ -1790,16 +1790,16 @@ static int net_check_prereq (proto_t protocol)
case NETCONS:
case TFTP:
if (NetServerIP == 0) {
- puts ("*** ERROR: `serverip' not set\n");
+ puts("*** ERROR: `serverip' not set\n");
return (1);
}
-#if defined(CONFIG_CMD_PING) || defined(CONFIG_CMD_SNTP) || \
- defined(CONFIG_CMD_DNS)
+#if defined(CONFIG_CMD_PING) || defined(CONFIG_CMD_SNTP) || \
+ defined(CONFIG_CMD_DNS)
common:
#endif
if (NetOurIP == 0) {
- puts ("*** ERROR: `ipaddr' not set\n");
+ puts("*** ERROR: `ipaddr' not set\n");
return (1);
}
/* Fall through */
@@ -1810,28 +1810,28 @@ static int net_check_prereq (proto_t protocol)
case BOOTP:
case CDP:
case DHCP:
- if (memcmp (NetOurEther, "\0\0\0\0\0\0", 6) == 0) {
+ if (memcmp(NetOurEther, "\0\0\0\0\0\0", 6) == 0) {
#ifdef CONFIG_NET_MULTI
- extern int eth_get_dev_index (void);
- int num = eth_get_dev_index ();
+ extern int eth_get_dev_index(void);
+ int num = eth_get_dev_index();
switch (num) {
case -1:
- puts ("*** ERROR: No ethernet found.\n");
+ puts("*** ERROR: No ethernet found.\n");
return (1);
case 0:
- puts ("*** ERROR: `ethaddr' not set\n");
+ puts("*** ERROR: `ethaddr' not set\n");
break;
default:
- printf ("*** ERROR: `eth%daddr' not set\n",
+ printf("*** ERROR: `eth%daddr' not set\n",
num);
break;
}
- NetStartAgain ();
+ NetStartAgain();
return (2);
#else
- puts ("*** ERROR: `ethaddr' not set\n");
+ puts("*** ERROR: `ethaddr' not set\n");
return (1);
#endif
}
@@ -1887,8 +1887,8 @@ NetSetEther(volatile uchar * xet, uchar * addr, uint prot)
if (myvlanid == (ushort)-1)
myvlanid = VLAN_NONE;
- memcpy (et->et_dest, addr, 6);
- memcpy (et->et_src, NetOurEther, 6);
+ memcpy(et->et_dest, addr, 6);
+ memcpy(et->et_src, NetOurEther, 6);
if ((myvlanid & VLAN_IDMASK) == VLAN_NONE) {
et->et_protlen = htons(prot);
return ETHER_HDR_SIZE;
@@ -1939,7 +1939,7 @@ NetSetIP(volatile uchar * xip, IPaddr_t dest, int dport, int sport, int len)
ip->ip_sum = ~NetCksum((uchar *)ip, IP_HDR_SIZE_NO_UDP / 2);
}
-void copy_filename (char *dst, const char *src, int size)
+void copy_filename(char *dst, const char *src, int size)
{
if (*src && (*src == '"')) {
++src;
@@ -1966,13 +1966,13 @@ unsigned int random_port(void)
}
#endif
-void ip_to_string (IPaddr_t x, char *s)
+void ip_to_string(IPaddr_t x, char *s)
{
- x = ntohl (x);
- sprintf (s, "%d.%d.%d.%d",
- (int) ((x >> 24) & 0xff),
- (int) ((x >> 16) & 0xff),
- (int) ((x >> 8) & 0xff), (int) ((x >> 0) & 0xff)
+ x = ntohl(x);
+ sprintf(s, "%d.%d.%d.%d",
+ (int) ((x >> 24) & 0xff),
+ (int) ((x >> 16) & 0xff),
+ (int) ((x >> 8) & 0xff), (int) ((x >> 0) & 0xff)
);
}
--
1.7.1
^ permalink raw reply related [flat|nested] 32+ messages in thread
* [U-Boot] [PATCH v2 4/8] net/net.c: cosmetic: fix brace issues
2011-05-04 12:40 [U-Boot] [PATCH 0/8] net/net.c: clenups for checkpatch compliance Luca Ceresoli
` (11 preceding siblings ...)
2011-05-11 13:59 ` [U-Boot] [PATCH v2 3/8] net/net.c: cosmetic: fix whitespace issues Luca Ceresoli
@ 2011-05-11 13:59 ` Luca Ceresoli
2011-05-12 20:17 ` Wolfgang Denk
2011-05-11 13:59 ` [U-Boot] [PATCH v2 5/8] net/net.c: cosmetic: fix pointer syntax issues Luca Ceresoli
` (3 subsequent siblings)
16 siblings, 1 reply; 32+ messages in thread
From: Luca Ceresoli @ 2011-05-11 13:59 UTC (permalink / raw)
To: u-boot
This removes the following checkpatch issues:
- WARNING: braces {} are not necessary for single statement blocks
- WARNING: braces {} are not necessary for any arm of this statement
Signed-off-by: Luca Ceresoli <luca.ceresoli@comelit.it>
Cc: Wolfgang Denk <wd@denx.de>
Cc: Ben Warren <biggerbadderben@gmail.com>
Cc: Mike Frysinger <vapier@gentoo.org>
---
Changes since v1: none.
net/net.c | 38 +++++++++++++-------------------------
1 files changed, 13 insertions(+), 25 deletions(-)
diff --git a/net/net.c b/net/net.c
index 172f4d5..c22da5f 100644
--- a/net/net.c
+++ b/net/net.c
@@ -367,9 +367,8 @@ NetLoop(proto_t protocol)
*/
NetTxPacket = &PktBuf[0] + (PKTALIGN - 1);
NetTxPacket -= (ulong)NetTxPacket % PKTALIGN;
- for (i = 0; i < PKTBUFSRX; i++) {
+ for (i = 0; i < PKTBUFSRX; i++)
NetRxPackets[i] = NetTxPacket + (i+1)*PKTSIZE_ALIGN;
- }
}
if (!NetArpWaitTxPacket) {
@@ -491,11 +490,10 @@ restart:
/*
* Echo the inverted link state to the fault LED.
*/
- if (miiphy_link(eth_get_dev()->name, CONFIG_SYS_FAULT_MII_ADDR)) {
+ if (miiphy_link(eth_get_dev()->name, CONFIG_SYS_FAULT_MII_ADDR))
status_led_set(STATUS_LED_RED, STATUS_LED_OFF);
- } else {
+ else
status_led_set(STATUS_LED_RED, STATUS_LED_ON);
- }
#endif /* CONFIG_SYS_FAULT_ECHO_LINK_DOWN, ... */
#endif /* CONFIG_MII, ... */
@@ -1096,9 +1094,8 @@ CDPHandler(const uchar * pkt, unsigned len)
ss = (const ushort *)pkt;
type = ntohs(ss[0]);
tlen = ntohs(ss[1]);
- if (tlen > len) {
+ if (tlen > len)
goto pkt_short;
- }
pkt += tlen;
len -= tlen;
@@ -1477,26 +1474,20 @@ NetReceive(volatile uchar * inpkt, int len)
printf("bad length %d < %d\n", len, ARP_HDR_SIZE);
return;
}
- if (ntohs(arp->ar_hrd) != ARP_ETHER) {
+ if (ntohs(arp->ar_hrd) != ARP_ETHER)
return;
- }
- if (ntohs(arp->ar_pro) != PROT_IP) {
+ if (ntohs(arp->ar_pro) != PROT_IP)
return;
- }
- if (arp->ar_hln != 6) {
+ if (arp->ar_hln != 6)
return;
- }
- if (arp->ar_pln != 4) {
+ if (arp->ar_pln != 4)
return;
- }
- if (NetOurIP == 0) {
+ if (NetOurIP == 0)
return;
- }
- if (NetReadIP(&arp->ar_data[16]) != NetOurIP) {
+ if (NetReadIP(&arp->ar_data[16]) != NetOurIP)
return;
- }
switch (ntohs(arp->ar_op)) {
case ARPOP_REQUEST:
@@ -1601,13 +1592,11 @@ NetReceive(volatile uchar * inpkt, int len)
debug("len=%d, v=%02x\n", len, ip->ip_hl_v & 0xff);
/* Can't deal with anything except IPv4 */
- if ((ip->ip_hl_v & 0xf0) != 0x40) {
+ if ((ip->ip_hl_v & 0xf0) != 0x40)
return;
- }
/* Can't deal with IP options (headers != 20 bytes) */
- if ((ip->ip_hl_v & 0x0f) > 0x05) {
+ if ((ip->ip_hl_v & 0x0f) > 0x05)
return;
- }
/* Check the Checksum of the header */
if (!NetCksumOk((uchar *)ip, IP_HDR_SIZE_NO_UDP / 2)) {
puts("checksum bad\n");
@@ -1946,9 +1935,8 @@ void copy_filename(char *dst, const char *src, int size)
--size;
}
- while ((--size > 0) && *src && (*src != '"')) {
+ while ((--size > 0) && *src && (*src != '"'))
*dst++ = *src++;
- }
*dst = '\0';
}
--
1.7.1
^ permalink raw reply related [flat|nested] 32+ messages in thread
* [U-Boot] [PATCH v2 5/8] net/net.c: cosmetic: fix pointer syntax issues
2011-05-04 12:40 [U-Boot] [PATCH 0/8] net/net.c: clenups for checkpatch compliance Luca Ceresoli
` (12 preceding siblings ...)
2011-05-11 13:59 ` [U-Boot] [PATCH v2 4/8] net/net.c: cosmetic: fix brace issues Luca Ceresoli
@ 2011-05-11 13:59 ` Luca Ceresoli
2011-05-12 20:17 ` Wolfgang Denk
2011-05-11 13:59 ` [U-Boot] [PATCH v2 6/8] net/net.c: cosmetic: parentheses not required for return Luca Ceresoli
` (2 subsequent siblings)
16 siblings, 1 reply; 32+ messages in thread
From: Luca Ceresoli @ 2011-05-11 13:59 UTC (permalink / raw)
To: u-boot
This removes the following checkpatch issues:
- ERROR: "foo * bar" should be "foo *bar"
- ERROR: "(foo*)" should be "(foo *)"
Signed-off-by: Luca Ceresoli <luca.ceresoli@comelit.it>
Cc: Wolfgang Denk <wd@denx.de>
Cc: Ben Warren <biggerbadderben@gmail.com>
Cc: Mike Frysinger <vapier@gentoo.org>
---
Changes since v1: none.
net/net.c | 36 ++++++++++++++++++------------------
1 files changed, 18 insertions(+), 18 deletions(-)
diff --git a/net/net.c b/net/net.c
index c22da5f..f8c852d 100644
--- a/net/net.c
+++ b/net/net.c
@@ -592,7 +592,7 @@ startAgainTimeout(void)
}
static void
-startAgainHandler(uchar * pkt, unsigned dest, unsigned src, unsigned len)
+startAgainHandler(uchar *pkt, unsigned dest, unsigned src, unsigned len)
{
/* Totally ignore the packet */
}
@@ -653,14 +653,14 @@ void NetStartAgain(void)
*/
void
-NetSetHandler(rxhand_f * f)
+NetSetHandler(rxhand_f *f)
{
packetHandler = f;
}
void
-NetSetTimeout(ulong iv, thand_f * f)
+NetSetTimeout(ulong iv, thand_f *f)
{
if (iv == 0) {
timeHandler = (thand_f *)0;
@@ -673,7 +673,7 @@ NetSetTimeout(ulong iv, thand_f * f)
void
-NetSendPacket(volatile uchar * pkt, int len)
+NetSendPacket(volatile uchar *pkt, int len)
{
(void) eth_send(pkt, len);
}
@@ -768,9 +768,9 @@ int PingSend(void)
ip->ip_p = 0x01; /* ICMP */
ip->ip_sum = 0;
/* already in network byte order */
- NetCopyIP((void*)&ip->ip_src, &NetOurIP);
+ NetCopyIP((void *)&ip->ip_src, &NetOurIP);
/* - "" - */
- NetCopyIP((void*)&ip->ip_dst, &NetPingIP);
+ NetCopyIP((void *)&ip->ip_dst, &NetPingIP);
ip->ip_sum = ~NetCksum((uchar *)ip, IP_HDR_SIZE_NO_UDP / 2);
s = &ip->udp_src; /* XXX ICMP starts here */
@@ -799,7 +799,7 @@ PingTimeout(void)
}
static void
-PingHandler(uchar * pkt, unsigned dest, unsigned src, unsigned len)
+PingHandler(uchar *pkt, unsigned dest, unsigned src, unsigned len)
{
IPaddr_t tmp;
volatile IP_t *ip = (volatile IP_t *)pkt;
@@ -1042,13 +1042,13 @@ CDPTimeout(void)
}
static void
-CDPDummyHandler(uchar * pkt, unsigned dest, unsigned src, unsigned len)
+CDPDummyHandler(uchar *pkt, unsigned dest, unsigned src, unsigned len)
{
/* nothing */
}
static void
-CDPHandler(const uchar * pkt, unsigned len)
+CDPHandler(const uchar *pkt, unsigned len)
{
const uchar *t;
const ushort *ss;
@@ -1354,7 +1354,7 @@ static inline IP_t *NetDefragment(IP_t *ip, int *lenp)
#endif
void
-NetReceive(volatile uchar * inpkt, int len)
+NetReceive(volatile uchar *inpkt, int len)
{
Ethernet_t *et;
IP_t *ip;
@@ -1662,8 +1662,8 @@ NetReceive(volatile uchar * inpkt, int len)
ip->ip_sum = 0;
ip->ip_off = 0;
- NetCopyIP((void*)&ip->ip_dst, &ip->ip_src);
- NetCopyIP((void*)&ip->ip_src, &NetOurIP);
+ NetCopyIP((void *)&ip->ip_dst, &ip->ip_src);
+ NetCopyIP((void *)&ip->ip_src, &NetOurIP);
ip->ip_sum = ~NetCksum((uchar *)ip,
IP_HDR_SIZE_NO_UDP >> 1);
@@ -1833,14 +1833,14 @@ static int net_check_prereq(proto_t protocol)
/**********************************************************************/
int
-NetCksumOk(uchar * ptr, int len)
+NetCksumOk(uchar *ptr, int len)
{
return !((NetCksum(ptr, len) + 1) & 0xfffe);
}
unsigned
-NetCksum(uchar * ptr, int len)
+NetCksum(uchar *ptr, int len)
{
ulong xsum;
ushort *p = (ushort *)ptr;
@@ -1867,7 +1867,7 @@ NetEthHdrSize(void)
}
int
-NetSetEther(volatile uchar * xet, uchar * addr, uint prot)
+NetSetEther(volatile uchar *xet, uchar * addr, uint prot)
{
Ethernet_t *et = (Ethernet_t *)xet;
ushort myvlanid;
@@ -1892,7 +1892,7 @@ NetSetEther(volatile uchar * xet, uchar * addr, uint prot)
}
void
-NetSetIP(volatile uchar * xip, IPaddr_t dest, int dport, int sport, int len)
+NetSetIP(volatile uchar *xip, IPaddr_t dest, int dport, int sport, int len)
{
IP_t *ip = (IP_t *)xip;
@@ -1918,9 +1918,9 @@ NetSetIP(volatile uchar * xip, IPaddr_t dest, int dport, int sport, int len)
ip->ip_p = 17; /* UDP */
ip->ip_sum = 0;
/* already in network byte order */
- NetCopyIP((void*)&ip->ip_src, &NetOurIP);
+ NetCopyIP((void *)&ip->ip_src, &NetOurIP);
/* - "" - */
- NetCopyIP((void*)&ip->ip_dst, &dest);
+ NetCopyIP((void *)&ip->ip_dst, &dest);
ip->udp_src = htons(sport);
ip->udp_dst = htons(dport);
ip->udp_len = htons(8 + len);
--
1.7.1
^ permalink raw reply related [flat|nested] 32+ messages in thread
* [U-Boot] [PATCH v2 6/8] net/net.c: cosmetic: parentheses not required for return
2011-05-04 12:40 [U-Boot] [PATCH 0/8] net/net.c: clenups for checkpatch compliance Luca Ceresoli
` (13 preceding siblings ...)
2011-05-11 13:59 ` [U-Boot] [PATCH v2 5/8] net/net.c: cosmetic: fix pointer syntax issues Luca Ceresoli
@ 2011-05-11 13:59 ` Luca Ceresoli
2011-05-12 20:18 ` Wolfgang Denk
2011-05-11 14:00 ` [U-Boot] [PATCH v2 7/8] net/net.c: cosmetic: fix indentation Luca Ceresoli
2011-05-11 14:00 ` [U-Boot] [PATCH v2 8/8] net/net.c: cosmetic: do not use assignment in if condition Luca Ceresoli
16 siblings, 1 reply; 32+ messages in thread
From: Luca Ceresoli @ 2011-05-11 13:59 UTC (permalink / raw)
To: u-boot
This removes the following checkpatch issue:
- ERROR: return is not a function, parentheses are not required
Signed-off-by: Luca Ceresoli <luca.ceresoli@comelit.it>
Cc: Wolfgang Denk <wd@denx.de>
Cc: Ben Warren <biggerbadderben@gmail.com>
Cc: Mike Frysinger <vapier@gentoo.org>
---
Changes since v1: none.
net/net.c | 30 +++++++++++++++---------------
1 files changed, 15 insertions(+), 15 deletions(-)
diff --git a/net/net.c b/net/net.c
index f8c852d..63fc60a 100644
--- a/net/net.c
+++ b/net/net.c
@@ -383,7 +383,7 @@ NetLoop(proto_t protocol)
#endif
if (eth_init(bd) < 0) {
eth_halt();
- return(-1);
+ return -1;
}
restart:
@@ -406,7 +406,7 @@ restart:
case 1:
/* network not configured */
eth_halt();
- return (-1);
+ return -1;
#ifdef CONFIG_NET_MULTI
case 2:
@@ -521,7 +521,7 @@ restart:
if (ctrlc()) {
eth_halt();
puts("\nAbort\n");
- return (-1);
+ return -1;
}
ArpTimeoutCheck();
@@ -578,7 +578,7 @@ restart:
return NetBootFileXferSize;
case NETLOOP_FAIL:
- return (-1);
+ return -1;
}
}
}
@@ -1753,7 +1753,7 @@ static int net_check_prereq(proto_t protocol)
case PING:
if (NetPingIP == 0) {
puts("*** ERROR: ping address not given\n");
- return (1);
+ return 1;
}
goto common;
#endif
@@ -1761,7 +1761,7 @@ static int net_check_prereq(proto_t protocol)
case SNTP:
if (NetNtpServerIP == 0) {
puts("*** ERROR: NTP server address not given\n");
- return (1);
+ return 1;
}
goto common;
#endif
@@ -1780,7 +1780,7 @@ static int net_check_prereq(proto_t protocol)
case TFTP:
if (NetServerIP == 0) {
puts("*** ERROR: `serverip' not set\n");
- return (1);
+ return 1;
}
#if defined(CONFIG_CMD_PING) || defined(CONFIG_CMD_SNTP) || \
defined(CONFIG_CMD_DNS)
@@ -1789,7 +1789,7 @@ static int net_check_prereq(proto_t protocol)
if (NetOurIP == 0) {
puts("*** ERROR: `ipaddr' not set\n");
- return (1);
+ return 1;
}
/* Fall through */
@@ -1807,7 +1807,7 @@ static int net_check_prereq(proto_t protocol)
switch (num) {
case -1:
puts("*** ERROR: No ethernet found.\n");
- return (1);
+ return 1;
case 0:
puts("*** ERROR: `ethaddr' not set\n");
break;
@@ -1818,17 +1818,17 @@ static int net_check_prereq(proto_t protocol)
}
NetStartAgain();
- return (2);
+ return 2;
#else
puts("*** ERROR: `ethaddr' not set\n");
- return (1);
+ return 1;
#endif
}
/* Fall through */
default:
- return (0);
+ return 0;
}
- return (0); /* OK */
+ return 0; /* OK */
}
/**********************************************************************/
@@ -1850,7 +1850,7 @@ NetCksum(uchar *ptr, int len)
xsum += *p++;
xsum = (xsum & 0xffff) + (xsum >> 16);
xsum = (xsum & 0xffff) + (xsum >> 16);
- return (xsum & 0xffff);
+ return xsum & 0xffff;
}
int
@@ -1994,5 +1994,5 @@ ushort string_to_VLAN(const char *s)
ushort getenv_VLAN(char *var)
{
- return (string_to_VLAN(getenv(var)));
+ return string_to_VLAN(getenv(var));
}
--
1.7.1
^ permalink raw reply related [flat|nested] 32+ messages in thread
* [U-Boot] [PATCH v2 7/8] net/net.c: cosmetic: fix indentation
2011-05-04 12:40 [U-Boot] [PATCH 0/8] net/net.c: clenups for checkpatch compliance Luca Ceresoli
` (14 preceding siblings ...)
2011-05-11 13:59 ` [U-Boot] [PATCH v2 6/8] net/net.c: cosmetic: parentheses not required for return Luca Ceresoli
@ 2011-05-11 14:00 ` Luca Ceresoli
2011-05-12 20:18 ` Wolfgang Denk
2011-05-11 14:00 ` [U-Boot] [PATCH v2 8/8] net/net.c: cosmetic: do not use assignment in if condition Luca Ceresoli
16 siblings, 1 reply; 32+ messages in thread
From: Luca Ceresoli @ 2011-05-11 14:00 UTC (permalink / raw)
To: u-boot
This removes the following checkpatch issues:
- ERROR: switch and case should be at the same indent
- WARNING: suspect code indent for conditional statements
- WARNING: labels should not be indented
Signed-off-by: Luca Ceresoli <luca.ceresoli@comelit.it>
Cc: Wolfgang Denk <wd@denx.de>
Cc: Ben Warren <biggerbadderben@gmail.com>
Cc: Mike Frysinger <vapier@gentoo.org>
---
Changes since v1: none.
net/net.c | 85 ++++++++++++++++++++++++++++++-------------------------------
1 files changed, 42 insertions(+), 43 deletions(-)
diff --git a/net/net.c b/net/net.c
index 63fc60a..8b4d28e 100644
--- a/net/net.c
+++ b/net/net.c
@@ -1104,51 +1104,50 @@ CDPHandler(const uchar *pkt, unsigned len)
tlen -= 4;
switch (type) {
- case CDP_DEVICE_ID_TLV:
- break;
- case CDP_ADDRESS_TLV:
- break;
- case CDP_PORT_ID_TLV:
- break;
- case CDP_CAPABILITIES_TLV:
- break;
- case CDP_VERSION_TLV:
- break;
- case CDP_PLATFORM_TLV:
- break;
- case CDP_NATIVE_VLAN_TLV:
- nvlan = *ss;
- break;
- case CDP_APPLIANCE_VLAN_TLV:
- t = (const uchar *)ss;
- while (tlen > 0) {
- if (tlen < 3)
- goto pkt_short;
+ case CDP_DEVICE_ID_TLV:
+ break;
+ case CDP_ADDRESS_TLV:
+ break;
+ case CDP_PORT_ID_TLV:
+ break;
+ case CDP_CAPABILITIES_TLV:
+ break;
+ case CDP_VERSION_TLV:
+ break;
+ case CDP_PLATFORM_TLV:
+ break;
+ case CDP_NATIVE_VLAN_TLV:
+ nvlan = *ss;
+ break;
+ case CDP_APPLIANCE_VLAN_TLV:
+ t = (const uchar *)ss;
+ while (tlen > 0) {
+ if (tlen < 3)
+ goto pkt_short;
- applid = t[0];
- ss = (const ushort *)(t + 1);
+ applid = t[0];
+ ss = (const ushort *)(t + 1);
#ifdef CONFIG_CDP_APPLIANCE_VLAN_TYPE
- if (applid ==
- CONFIG_CDP_APPLIANCE_VLAN_TYPE)
- vlan = *ss;
+ if (applid == CONFIG_CDP_APPLIANCE_VLAN_TYPE)
+ vlan = *ss;
#else
- /* XXX will this work; dunno */
- vlan = ntohs(*ss);
+ /* XXX will this work; dunno */
+ vlan = ntohs(*ss);
#endif
- t += 3; tlen -= 3;
- }
- break;
- case CDP_TRIGGER_TLV:
- break;
- case CDP_POWER_CONSUMPTION_TLV:
- break;
- case CDP_SYSNAME_TLV:
- break;
- case CDP_SYSOBJECT_TLV:
- break;
- case CDP_MANAGEMENT_ADDRESS_TLV:
- break;
+ t += 3; tlen -= 3;
+ }
+ break;
+ case CDP_TRIGGER_TLV:
+ break;
+ case CDP_POWER_CONSUMPTION_TLV:
+ break;
+ case CDP_SYSNAME_TLV:
+ break;
+ case CDP_SYSOBJECT_TLV:
+ break;
+ case CDP_MANAGEMENT_ADDRESS_TLV:
+ break;
}
}
@@ -1608,7 +1607,7 @@ NetReceive(volatile uchar *inpkt, int len)
#ifdef CONFIG_MCAST_TFTP
if (Mcast_addr != tmp)
#endif
- return;
+ return;
}
/*
* The function returns the unchanged packet if it's not
@@ -1784,7 +1783,7 @@ static int net_check_prereq(proto_t protocol)
}
#if defined(CONFIG_CMD_PING) || defined(CONFIG_CMD_SNTP) || \
defined(CONFIG_CMD_DNS)
- common:
+common:
#endif
if (NetOurIP == 0) {
@@ -1879,7 +1878,7 @@ NetSetEther(volatile uchar *xet, uchar * addr, uint prot)
memcpy(et->et_dest, addr, 6);
memcpy(et->et_src, NetOurEther, 6);
if ((myvlanid & VLAN_IDMASK) == VLAN_NONE) {
- et->et_protlen = htons(prot);
+ et->et_protlen = htons(prot);
return ETHER_HDR_SIZE;
} else {
VLAN_Ethernet_t *vet = (VLAN_Ethernet_t *)xet;
--
1.7.1
^ permalink raw reply related [flat|nested] 32+ messages in thread
* [U-Boot] [PATCH v2 8/8] net/net.c: cosmetic: do not use assignment in if condition
2011-05-04 12:40 [U-Boot] [PATCH 0/8] net/net.c: clenups for checkpatch compliance Luca Ceresoli
` (15 preceding siblings ...)
2011-05-11 14:00 ` [U-Boot] [PATCH v2 7/8] net/net.c: cosmetic: fix indentation Luca Ceresoli
@ 2011-05-11 14:00 ` Luca Ceresoli
2011-05-12 20:18 ` Wolfgang Denk
16 siblings, 1 reply; 32+ messages in thread
From: Luca Ceresoli @ 2011-05-11 14:00 UTC (permalink / raw)
To: u-boot
This removes the following checkpatch issue:
- ERROR: do not use assignment in if condition
Signed-off-by: Luca Ceresoli <luca.ceresoli@comelit.it>
Cc: Wolfgang Denk <wd@denx.de>
Cc: Ben Warren <biggerbadderben@gmail.com>
Cc: Mike Frysinger <vapier@gentoo.org>
---
Changes since v1: none.
net/net.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/net/net.c b/net/net.c
index 8b4d28e..1c4c982 100644
--- a/net/net.c
+++ b/net/net.c
@@ -1614,7 +1614,8 @@ NetReceive(volatile uchar *inpkt, int len)
* a fragment, and either the complete packet or NULL if
* it is a fragment (if !CONFIG_IP_DEFRAG, it returns NULL)
*/
- if (!(ip = NetDefragment(ip, &len)))
+ ip = NetDefragment(ip, &len);
+ if (!ip)
return;
/*
* watch for ICMP host redirects
--
1.7.1
^ permalink raw reply related [flat|nested] 32+ messages in thread
* [U-Boot] [PATCH v2 1/8] net/net.c: cosmetic: fix lines over 80 characters
2011-05-11 13:59 ` [U-Boot] [PATCH v2 1/8] net/net.c: cosmetic: fix lines over 80 characters Luca Ceresoli
@ 2011-05-12 20:14 ` Wolfgang Denk
0 siblings, 0 replies; 32+ messages in thread
From: Wolfgang Denk @ 2011-05-12 20:14 UTC (permalink / raw)
To: u-boot
Dear Luca Ceresoli,
In message <1305122401-14967-2-git-send-email-luca.ceresoli@comelit.it> you wrote:
> This removes the following checkpatch warning:
> - WARNING: line over 80 characters
>
> There are three such warnings left.
>
> The first is hard to fix with cosmetic-only changes without compromising code
> readability, so I'm leaving it as it is for now:
> WARNING: line over 80 characters
> #1537: FILE: net.c:1537:
> + [4 tabs] memcpy(((Ethernet_t *)NetArpWaitTxPacket)->et_dest, ...
>
> The other two cannot be fixed without splitting string literals, so it is
> preferred to keep them longer than 80 characters.
>
> Signed-off-by: Luca Ceresoli <luca.ceresoli@comelit.it>
> Cc: Wolfgang Denk <wd@denx.de>
> Cc: Ben Warren <biggerbadderben@gmail.com>
> Cc: Mike Frysinger <vapier@gentoo.org>
Applied, thanks.
Best regards,
Wolfgang Denk
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
You can't have everything... where would you put it? - Steven Wright
^ permalink raw reply [flat|nested] 32+ messages in thread
* [U-Boot] [PATCH v2 2/8] net/net.c: cosmetic: variable initializations
2011-05-11 13:59 ` [U-Boot] [PATCH v2 2/8] net/net.c: cosmetic: variable initializations Luca Ceresoli
@ 2011-05-12 20:17 ` Wolfgang Denk
0 siblings, 0 replies; 32+ messages in thread
From: Wolfgang Denk @ 2011-05-12 20:17 UTC (permalink / raw)
To: u-boot
Dear Luca Ceresoli,
In message <1305122401-14967-3-git-send-email-luca.ceresoli@comelit.it> you wrote:
> This removes the following checkpatch errors:
> - ERROR: do not initialise globals to 0 or NULL
> - ERROR: spaces required around that '=' (ctx:VxV)
> - ERROR: that open brace { should be on the previous line
>
> Signed-off-by: Luca Ceresoli <luca.ceresoli@comelit.it>
> Cc: Wolfgang Denk <wd@denx.de>
> Cc: Ben Warren <biggerbadderben@gmail.com>
> Cc: Mike Frysinger <vapier@gentoo.org>
>
> ---
> Changes since v1:
> - re-fix array initializations (the fix in v1 was worse than the original).
>
> net/net.c | 40 ++++++++++++++++++----------------------
> 1 files changed, 18 insertions(+), 22 deletions(-)
Applied, thanks.
Best regards,
Wolfgang Denk
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Let's say the docs present a simplified view of reality... :-)
- Larry Wall in <6940@jpl-devvax.JPL.NASA.GOV>
^ permalink raw reply [flat|nested] 32+ messages in thread
* [U-Boot] [PATCH v2 3/8] net/net.c: cosmetic: fix whitespace issues
2011-05-11 13:59 ` [U-Boot] [PATCH v2 3/8] net/net.c: cosmetic: fix whitespace issues Luca Ceresoli
@ 2011-05-12 20:17 ` Wolfgang Denk
0 siblings, 0 replies; 32+ messages in thread
From: Wolfgang Denk @ 2011-05-12 20:17 UTC (permalink / raw)
To: u-boot
Dear Luca Ceresoli,
In message <1305122401-14967-4-git-send-email-luca.ceresoli@comelit.it> you wrote:
> This removes the following checkpatch issues:
> - ERROR: space prohibited after that open parenthesis '('
> - ERROR: space prohibited before that close parenthesis ')'
> - ERROR: space prohibited after that open square bracket '['
> - ERROR: space prohibited after that '&' (ctx:WxW)
> - ERROR: spaces required around that '=' (ctx:VxW)
> - ERROR: space required before the open parenthesis '('
> - ERROR: space required after that ',' (ctx:VxV)
> - ERROR: need consistent spacing around '+' (ctx:WxV)
> - WARNING: unnecessary whitespace before a quoted newline
> - WARNING: please, no spaces at the start of a line
> - WARNING: space prohibited between function name and open
> parenthesis '('
>
> Signed-off-by: Luca Ceresoli <luca.ceresoli@comelit.it>
> Cc: Wolfgang Denk <wd@denx.de>
> Cc: Ben Warren <biggerbadderben@gmail.com>
> Cc: Mike Frysinger <vapier@gentoo.org>
>
> ---
> Changes since v1: none.
>
> net/net.c | 192 ++++++++++++++++++++++++++++++------------------------------
> 1 files changed, 96 insertions(+), 96 deletions(-)
Applied, thanks.
Best regards,
Wolfgang Denk
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Disobedience: The silver lining to the cloud of servitude.
- Ambrose Bierce
^ permalink raw reply [flat|nested] 32+ messages in thread
* [U-Boot] [PATCH v2 4/8] net/net.c: cosmetic: fix brace issues
2011-05-11 13:59 ` [U-Boot] [PATCH v2 4/8] net/net.c: cosmetic: fix brace issues Luca Ceresoli
@ 2011-05-12 20:17 ` Wolfgang Denk
0 siblings, 0 replies; 32+ messages in thread
From: Wolfgang Denk @ 2011-05-12 20:17 UTC (permalink / raw)
To: u-boot
Dear Luca Ceresoli,
In message <1305122401-14967-5-git-send-email-luca.ceresoli@comelit.it> you wrote:
> This removes the following checkpatch issues:
> - WARNING: braces {} are not necessary for single statement blocks
> - WARNING: braces {} are not necessary for any arm of this statement
>
> Signed-off-by: Luca Ceresoli <luca.ceresoli@comelit.it>
> Cc: Wolfgang Denk <wd@denx.de>
> Cc: Ben Warren <biggerbadderben@gmail.com>
> Cc: Mike Frysinger <vapier@gentoo.org>
>
> ---
> Changes since v1: none.
>
> net/net.c | 38 +++++++++++++-------------------------
> 1 files changed, 13 insertions(+), 25 deletions(-)
Applied, thanks.
Best regards,
Wolfgang Denk
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
All repairs tend to destroy the structure, to increase the entropy
and disorder of the system. Less and less effort is spent on fixing
original design flaws; more and more is spent on fixing flaws intro-
duced by earlier fixes. - Fred Brooks, "The Mythical Man Month"
^ permalink raw reply [flat|nested] 32+ messages in thread
* [U-Boot] [PATCH v2 5/8] net/net.c: cosmetic: fix pointer syntax issues
2011-05-11 13:59 ` [U-Boot] [PATCH v2 5/8] net/net.c: cosmetic: fix pointer syntax issues Luca Ceresoli
@ 2011-05-12 20:17 ` Wolfgang Denk
0 siblings, 0 replies; 32+ messages in thread
From: Wolfgang Denk @ 2011-05-12 20:17 UTC (permalink / raw)
To: u-boot
Dear Luca Ceresoli,
In message <1305122401-14967-6-git-send-email-luca.ceresoli@comelit.it> you wrote:
> This removes the following checkpatch issues:
> - ERROR: "foo * bar" should be "foo *bar"
> - ERROR: "(foo*)" should be "(foo *)"
>
> Signed-off-by: Luca Ceresoli <luca.ceresoli@comelit.it>
> Cc: Wolfgang Denk <wd@denx.de>
> Cc: Ben Warren <biggerbadderben@gmail.com>
> Cc: Mike Frysinger <vapier@gentoo.org>
>
> ---
> Changes since v1: none.
>
> net/net.c | 36 ++++++++++++++++++------------------
> 1 files changed, 18 insertions(+), 18 deletions(-)
Applied, thanks.
Best regards,
Wolfgang Denk
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
I wrote my name at the top of the page. I wrote down the number of
the question ``1''. After much reflection I put a bracket round it
thus ``(1)''. But thereafter I could not think of anything connected
with it that was either relevant or true.
- Sir Winston Churchill _My Early Life_ ch. 2
^ permalink raw reply [flat|nested] 32+ messages in thread
* [U-Boot] [PATCH v2 6/8] net/net.c: cosmetic: parentheses not required for return
2011-05-11 13:59 ` [U-Boot] [PATCH v2 6/8] net/net.c: cosmetic: parentheses not required for return Luca Ceresoli
@ 2011-05-12 20:18 ` Wolfgang Denk
0 siblings, 0 replies; 32+ messages in thread
From: Wolfgang Denk @ 2011-05-12 20:18 UTC (permalink / raw)
To: u-boot
Dear Luca Ceresoli,
In message <1305122401-14967-7-git-send-email-luca.ceresoli@comelit.it> you wrote:
> This removes the following checkpatch issue:
> - ERROR: return is not a function, parentheses are not required
>
> Signed-off-by: Luca Ceresoli <luca.ceresoli@comelit.it>
> Cc: Wolfgang Denk <wd@denx.de>
> Cc: Ben Warren <biggerbadderben@gmail.com>
> Cc: Mike Frysinger <vapier@gentoo.org>
>
> ---
> Changes since v1: none.
>
> net/net.c | 30 +++++++++++++++---------------
> 1 files changed, 15 insertions(+), 15 deletions(-)
Applied, thanks.
Best regards,
Wolfgang Denk
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
The first 90% of a project takes 90% of the time, the last 10% takes
the other 90% of the time.
^ permalink raw reply [flat|nested] 32+ messages in thread
* [U-Boot] [PATCH v2 7/8] net/net.c: cosmetic: fix indentation
2011-05-11 14:00 ` [U-Boot] [PATCH v2 7/8] net/net.c: cosmetic: fix indentation Luca Ceresoli
@ 2011-05-12 20:18 ` Wolfgang Denk
0 siblings, 0 replies; 32+ messages in thread
From: Wolfgang Denk @ 2011-05-12 20:18 UTC (permalink / raw)
To: u-boot
Dear Luca Ceresoli,
In message <1305122401-14967-8-git-send-email-luca.ceresoli@comelit.it> you wrote:
> This removes the following checkpatch issues:
> - ERROR: switch and case should be at the same indent
> - WARNING: suspect code indent for conditional statements
> - WARNING: labels should not be indented
>
> Signed-off-by: Luca Ceresoli <luca.ceresoli@comelit.it>
> Cc: Wolfgang Denk <wd@denx.de>
> Cc: Ben Warren <biggerbadderben@gmail.com>
> Cc: Mike Frysinger <vapier@gentoo.org>
>
> ---
> Changes since v1: none.
>
> net/net.c | 85 ++++++++++++++++++++++++++++++-------------------------------
> 1 files changed, 42 insertions(+), 43 deletions(-)
Applied, thanks.
Best regards,
Wolfgang Denk
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Do you suppose the reason the ends of the `Intel Inside' logo don't
match up is that it was drawn on a Pentium?
^ permalink raw reply [flat|nested] 32+ messages in thread
* [U-Boot] [PATCH v2 8/8] net/net.c: cosmetic: do not use assignment in if condition
2011-05-11 14:00 ` [U-Boot] [PATCH v2 8/8] net/net.c: cosmetic: do not use assignment in if condition Luca Ceresoli
@ 2011-05-12 20:18 ` Wolfgang Denk
0 siblings, 0 replies; 32+ messages in thread
From: Wolfgang Denk @ 2011-05-12 20:18 UTC (permalink / raw)
To: u-boot
Dear Luca Ceresoli,
In message <1305122401-14967-9-git-send-email-luca.ceresoli@comelit.it> you wrote:
> This removes the following checkpatch issue:
> - ERROR: do not use assignment in if condition
>
> Signed-off-by: Luca Ceresoli <luca.ceresoli@comelit.it>
> Cc: Wolfgang Denk <wd@denx.de>
> Cc: Ben Warren <biggerbadderben@gmail.com>
> Cc: Mike Frysinger <vapier@gentoo.org>
>
> ---
> Changes since v1: none.
>
> net/net.c | 3 ++-
> 1 files changed, 2 insertions(+), 1 deletions(-)
Applied, thanks.
Best regards,
Wolfgang Denk
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
You humans have that emotional need to express gratitude. "You're
welcome," I believe, is the correct response.
-- Spock, "Bread and Circuses", stardate 4041.2
^ permalink raw reply [flat|nested] 32+ messages in thread
end of thread, other threads:[~2011-05-12 20:18 UTC | newest]
Thread overview: 32+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-04 12:40 [U-Boot] [PATCH 0/8] net/net.c: clenups for checkpatch compliance Luca Ceresoli
2011-05-04 12:40 ` [U-Boot] [PATCH 1/8] net/net.c: cosmetic: fix lines over 80 characters Luca Ceresoli
2011-05-09 19:42 ` Mike Frysinger
2011-05-10 7:13 ` Luca Ceresoli
2011-05-10 15:51 ` Mike Frysinger
2011-05-04 12:40 ` [U-Boot] [PATCH 2/8] net/net.c: cosmetic: variable initializations Luca Ceresoli
2011-05-04 13:16 ` Mike Frysinger
2011-05-04 16:42 ` Luca Ceresoli
2011-05-05 7:54 ` Mike Frysinger
2011-05-04 12:40 ` [U-Boot] [PATCH 3/8] net/net.c: cosmetic: fix whitespace issues Luca Ceresoli
2011-05-04 12:40 ` [U-Boot] [PATCH 4/8] net/net.c: cosmetic: fix brace issues Luca Ceresoli
2011-05-04 12:40 ` [U-Boot] [PATCH 5/8] net/net.c: cosmetic: fix pointer syntax issues Luca Ceresoli
2011-05-04 12:40 ` [U-Boot] [PATCH 6/8] net/net.c: cosmetic: parentheses not required for return Luca Ceresoli
2011-05-04 12:40 ` [U-Boot] [PATCH 7/8] net/net.c: cosmetic: fix indentation Luca Ceresoli
2011-05-04 12:40 ` [U-Boot] [PATCH 8/8] net/net.c: cosmetic: do not use assignment in if condition Luca Ceresoli
2011-05-11 13:59 ` [U-Boot] [PATCH v2 0/8] net/net.c: cleanups for checkpatch compliance Luca Ceresoli
2011-05-11 13:59 ` [U-Boot] [PATCH v2 1/8] net/net.c: cosmetic: fix lines over 80 characters Luca Ceresoli
2011-05-12 20:14 ` Wolfgang Denk
2011-05-11 13:59 ` [U-Boot] [PATCH v2 2/8] net/net.c: cosmetic: variable initializations Luca Ceresoli
2011-05-12 20:17 ` Wolfgang Denk
2011-05-11 13:59 ` [U-Boot] [PATCH v2 3/8] net/net.c: cosmetic: fix whitespace issues Luca Ceresoli
2011-05-12 20:17 ` Wolfgang Denk
2011-05-11 13:59 ` [U-Boot] [PATCH v2 4/8] net/net.c: cosmetic: fix brace issues Luca Ceresoli
2011-05-12 20:17 ` Wolfgang Denk
2011-05-11 13:59 ` [U-Boot] [PATCH v2 5/8] net/net.c: cosmetic: fix pointer syntax issues Luca Ceresoli
2011-05-12 20:17 ` Wolfgang Denk
2011-05-11 13:59 ` [U-Boot] [PATCH v2 6/8] net/net.c: cosmetic: parentheses not required for return Luca Ceresoli
2011-05-12 20:18 ` Wolfgang Denk
2011-05-11 14:00 ` [U-Boot] [PATCH v2 7/8] net/net.c: cosmetic: fix indentation Luca Ceresoli
2011-05-12 20:18 ` Wolfgang Denk
2011-05-11 14:00 ` [U-Boot] [PATCH v2 8/8] net/net.c: cosmetic: do not use assignment in if condition Luca Ceresoli
2011-05-12 20:18 ` Wolfgang Denk
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.