[U-Boot] [PATCH] net: Add labels to endifs and remove impossible conditional code block

2010-10-21 Thread Gray Remlin
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_rem...@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 

Re: [U-Boot] [PATCH] net: Add labels to endifs and remove impossible conditional code block

2010-10-21 Thread Wolfgang Denk
Dear Gray Remlin,

In message 4cc09695.6070...@rocketmail.com you wrote:
 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.
...

 -#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

What makes you think CONFIG_CMD_DHCP was never used? There are 270+
boards that use this!

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: w...@denx.de
Technology is dominated by those who manage what they do  not  under-
stand.
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH] net: Add labels to endifs and remove impossible conditional code block

2010-10-21 Thread Reinhard Meyer
Dear Wolfgang Denk,
 In message4cc09695.6070...@rocketmail.com  you wrote:
 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.
 ...

 -#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

 What makes you think CONFIG_CMD_DHCP was never used? There are 270+
 boards that use this!

Its in the ELSE part like this:

#if defined(CONFIG_CMD_DHCP)
...
#else
...
#if defined(CONFIG_CMD_DHCP)
...
#endif
...
#endif

Perhaps it should be investigated how it happened to become such dead code?

Best Regards,
Reinhard
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot