[U-Boot] [PATCH] net: Add labels to endifs and remove impossible conditional code block
Gray Remlin
g_remlin at rocketmail.com
Thu Oct 21 21:37:57 CEST 2010
Labels added to endifs to aid readability of the net/bootp.c file.
A block of code was marked for conditional compilation but the condition
could never arise, the ifdef\endif code block has been deleted.
Signed-off-by: Gray Remlin <g_remlin at rocketmail.com>
---
net/bootp.c | 93
++++++++++++++++++++++++++---------------------------------
1 files changed, 41 insertions(+), 52 deletions(-)
diff --git a/net/bootp.c b/net/bootp.c
index e679f8b..45abb46 100644
--- a/net/bootp.c
+++ b/net/bootp.c
@@ -66,9 +66,9 @@ static char *dhcpmsg2str(int type)
#if defined(CONFIG_BOOTP_VENDOREX)
extern u8 *dhcp_vendorex_prep (u8 *e); /*rtn new e after add own opts. */
extern u8 *dhcp_vendorex_proc (u8 *e); /*rtn next e if mine,else NULL */
-#endif
+#endif /* CONFIG_BOOTP_VENDOREX */
-#endif
+#endif /* CONFIG_CMD_DHCP */
static int BootpCheckPkt(uchar *pkt, unsigned dest, unsigned src,
unsigned len)
{
@@ -112,7 +112,7 @@ static void BootpCopyNetParams(Bootp_t *bp)
if (tmp_ip != 0)
NetCopyIP(&NetServerIP, &bp->bp_siaddr);
memcpy (NetServerEther, ((Ethernet_t *)NetRxPacket)->et_src, 6);
-#endif
+#endif /* CONFIG_BOOTP_SERVERIP */
if (strlen(bp->bp_file) > 0)
copy_filename (BootFile, bp->bp_file, sizeof(BootFile));
@@ -174,7 +174,7 @@ static void BootpVendorFieldProcess (u8 * ext)
if ((NetOurDNS2IP == 0) && (size > 4)) {
NetCopyIP (&NetOurDNS2IP, (IPaddr_t *) (ext + 2
+ 4));
}
-#endif
+#endif /* CONFIG_BOOTP_DNS2 */
break;
case 7: /* Log server - Not yet supported
*/
break;
@@ -300,7 +300,7 @@ BootpHandler(uchar * pkt, unsigned dest, unsigned
src, unsigned len)
*/
#ifdef CONFIG_STATUS_LED
status_led_set (STATUS_LED_BOOT, STATUS_LED_OFF);
-#endif
+#endif /* CONFIG_STATUS_LED */
BootpCopyNetParams(bp); /* Store net parameters from
reply */
@@ -327,13 +327,13 @@ BootpHandler(uchar * pkt, unsigned dest, unsigned
src, unsigned len)
*/
NfsStart();
return;
-#endif
+#endif /* CONFIG_CMD_NFS */
}
}
TftpStart();
}
-#endif
+#endif /* CONFIG_CMD_DHCP */
/*
* Timeout on BOOTP/DHCP request.
@@ -361,10 +361,10 @@ static int DhcpExtended (u8 * e, int message_type,
IPaddr_t ServerID, IPaddr_t R
#if defined(CONFIG_BOOTP_VENDOREX)
u8 *x;
-#endif
+#endif /* CONFIG_BOOTP_VENDOREX */
#if defined(CONFIG_BOOTP_SEND_HOSTNAME)
char *hostname;
-#endif
+#endif /* CONFIG_BOOTP_SEND_HOSTNAME */
*e++ = 99; /* RFC1048 Magic Cookie */
*e++ = 130;
@@ -410,12 +410,12 @@ static int DhcpExtended (u8 * e, int message_type,
IPaddr_t ServerID, IPaddr_t R
memcpy (e, hostname, hostnamelen);
e += hostnamelen;
}
-#endif
+#endif /* CONFIG_BOOTP_SEND_HOSTNAME */
#if defined(CONFIG_BOOTP_VENDOREX)
if ((x = dhcp_vendorex_prep (e)))
return x - start;
-#endif
+#endif /* CONFIG_BOOTP_VENDOREX */
*e++ = 55; /* Parameter Request List */
cnt = e++; /* Pointer to count of requested items */
@@ -423,51 +423,51 @@ static int DhcpExtended (u8 * e, int message_type,
IPaddr_t ServerID, IPaddr_t R
#if defined(CONFIG_BOOTP_SUBNETMASK)
*e++ = 1; /* Subnet Mask */
*cnt += 1;
-#endif
+#endif /* CONFIG_BOOTP_SUBNETMASK */
#if defined(CONFIG_BOOTP_TIMEOFFSET)
*e++ = 2;
*cnt += 1;
-#endif
+#endif /* CONFIG_BOOTP_TIMEOFFSET */
#if defined(CONFIG_BOOTP_GATEWAY)
*e++ = 3; /* Router Option */
*cnt += 1;
-#endif
+#endif /* CONFIG_BOOTP_GATEWAY */
#if defined(CONFIG_BOOTP_DNS)
*e++ = 6; /* DNS Server(s) */
*cnt += 1;
-#endif
+#endif /* CONFIG_BOOTP_DNS */
#if defined(CONFIG_BOOTP_HOSTNAME)
*e++ = 12; /* Hostname */
*cnt += 1;
-#endif
+#endif /* CONFIG_BOOTP_HOSTNAME */
#if defined(CONFIG_BOOTP_BOOTFILESIZE)
*e++ = 13; /* Boot File Size */
*cnt += 1;
-#endif
+#endif /* CONFIG_BOOTP_BOOTFILESIZE */
#if defined(CONFIG_BOOTP_BOOTPATH)
*e++ = 17; /* Boot path */
*cnt += 1;
-#endif
+#endif /* CONFIG_BOOTP_BOOTPATH */
#if defined(CONFIG_BOOTP_NISDOMAIN)
*e++ = 40; /* NIS Domain name request */
*cnt += 1;
-#endif
+#endif /* CONFIG_BOOTP_NISDOMAIN */
#if defined(CONFIG_BOOTP_NTPSERVER)
*e++ = 42;
*cnt += 1;
-#endif
+#endif /* CONFIG_BOOTP_NTPSERVER */
*e++ = 255; /* End of the list */
/* Pad to minimal length */
#ifdef CONFIG_DHCP_MIN_EXT_LEN
while ((e - start) <= CONFIG_DHCP_MIN_EXT_LEN)
*e++ = 0;
-#endif
+#endif /* CONFIG_DHCP_MIN_EXT_LEN */
return e - start;
}
-#else
+#else /* CONFIG_CMD_DHCP */
/*
* Warning: no field size check - change CONFIG_BOOTP_* at your own
risk!
*/
@@ -480,64 +480,53 @@ static int BootpExtended (u8 * e)
*e++ = 83;
*e++ = 99;
-#if defined(CONFIG_CMD_DHCP)
- *e++ = 53; /* DHCP Message Type */
- *e++ = 1;
- *e++ = DHCP_DISCOVER;
-
- *e++ = 57; /* Maximum DHCP Message Size */
- *e++ = 2;
- *e++ = (576 - 312 + OPT_SIZE) >> 16;
- *e++ = (576 - 312 + OPT_SIZE) & 0xff;
-#endif
-
#if defined(CONFIG_BOOTP_SUBNETMASK)
*e++ = 1; /* Subnet mask request */
*e++ = 4;
e += 4;
-#endif
+#endif /* CONFIG_BOOTP_SUBNETMASK */
#if defined(CONFIG_BOOTP_GATEWAY)
*e++ = 3; /* Default gateway request */
*e++ = 4;
e += 4;
-#endif
+#endif /* CONFIG_BOOTP_GATEWAY */
#if defined(CONFIG_BOOTP_DNS)
*e++ = 6; /* Domain Name Server */
*e++ = 4;
e += 4;
-#endif
+#endif /* CONFIG_BOOTP_DNS */
#if defined(CONFIG_BOOTP_HOSTNAME)
*e++ = 12; /* Host name request */
*e++ = 32;
e += 32;
-#endif
+#endif /* CONFIG_BOOTP_HOSTNAME */
#if defined(CONFIG_BOOTP_BOOTFILESIZE)
*e++ = 13; /* Boot file size */
*e++ = 2;
e += 2;
-#endif
+#endif /* CONFIG_BOOTP_BOOTFILESIZE */
#if defined(CONFIG_BOOTP_BOOTPATH)
*e++ = 17; /* Boot path */
*e++ = 32;
e += 32;
-#endif
+#endif /* CONFIG_BOOTP_BOOTPATH */
#if defined(CONFIG_BOOTP_NISDOMAIN)
*e++ = 40; /* NIS Domain name request */
*e++ = 32;
e += 32;
-#endif
+#endif /* CONFIG_BOOTP_NISDOMAIN */
*e++ = 255; /* End of the list */
return e - start;
}
-#endif
+#endif /* CONFIG_CMD_DHCP */
void
BootpRequest (void)
@@ -548,7 +537,7 @@ BootpRequest (void)
#if defined(CONFIG_CMD_DHCP)
dhcp_state = INIT;
-#endif
+#endif /* CONFIG_CMD_DHCP */
#ifdef CONFIG_BOOTP_RANDOM_DELAY /* Random BOOTP delay */
unsigned char bi_enetaddr[6];
@@ -642,9 +631,9 @@ BootpRequest (void)
/* Request additional information from the BOOTP/DHCP server */
#if defined(CONFIG_CMD_DHCP)
ext_len = DhcpExtended((u8 *)bp->bp_vend, DHCP_DISCOVER, 0, 0);
-#else
+#else /* CONFIG_CMD_DHCP */
ext_len = BootpExtended((u8 *)bp->bp_vend);
-#endif
+#endif /* CONFIG_CMD_DHCP */
/*
* Bootp ID is the lower 4 bytes of our ethernet address
@@ -670,9 +659,9 @@ BootpRequest (void)
#if defined(CONFIG_CMD_DHCP)
dhcp_state = SELECTING;
NetSetHandler(DhcpHandler);
-#else
+#else /* CONFIG_CMD_DHCP */
NetSetHandler(BootpHandler);
-#endif
+#endif /* CONFIG_CMD_DHCP */
NetSendPacket(NetTxPacket, pktlen);
}
@@ -683,7 +672,7 @@ static void DhcpOptionsProcess (uchar * popt,
Bootp_t *bp)
int oplen, size;
#if defined(CONFIG_CMD_SNTP) && defined(CONFIG_BOOTP_TIMEOFFSET)
int *to_ptr;
-#endif
+#endif /* CONFIG_CMD_SNTP */
while (popt < end && *popt != 0xff) {
oplen = *(popt + 1);
@@ -697,7 +686,7 @@ static void DhcpOptionsProcess (uchar * popt,
Bootp_t *bp)
NetCopyLong ((ulong *)to_ptr, (ulong *)(popt + 2));
NetTimeOffset = ntohl (NetTimeOffset);
break;
-#endif
+#endif /* CONFIG_CMD_SNTP */
case 3:
NetCopyIP (&NetOurGatewayIP, (popt + 2));
break;
@@ -707,7 +696,7 @@ static void DhcpOptionsProcess (uchar * popt,
Bootp_t *bp)
if (*(popt + 1) > 4) {
NetCopyIP (&NetOurDNS2IP, (popt + 2 + 4));
}
-#endif
+#endif /* CONFIG_BOOTP_DNS2 */
break;
case 12:
size = truncate_sz ("Host Name", sizeof
(NetOurHostName), oplen);
@@ -725,7 +714,7 @@ static void DhcpOptionsProcess (uchar * popt,
Bootp_t *bp)
case 42: /* NTP server IP */
NetCopyIP (&NetNtpServerIP, (popt + 2));
break;
-#endif
+#endif /* CONFIG_CMD_SNTP && CONFIG_BOOTP_NTPSERVER */
case 51:
NetCopyLong (&dhcp_leasetime, (ulong *) (popt + 2));
break;
@@ -770,7 +759,7 @@ static void DhcpOptionsProcess (uchar * popt,
Bootp_t *bp)
#if defined(CONFIG_BOOTP_VENDOREX)
if (dhcp_vendorex_proc (popt))
break;
-#endif
+#endif /* CONFIG_BOOTP_VENDOREX */
printf ("*** Unhandled DHCP Option in OFFER/ACK:
%d\n", *popt);
break;
}
@@ -924,7 +913,7 @@ DhcpHandler(uchar * pkt, unsigned dest, unsigned
src, unsigned len)
*/
NfsStart();
return;
-#endif
+#endif /* CONFIG_CMD_NFS */
}
}
TftpStart();
--
More information about the U-Boot
mailing list