$ egrep _ARPING include/autoconf.h
#define CONFIG_ARPING 1
#define ENABLE_ARPING 1
#define USE_ARPING(...) __VA_ARGS__
#define SKIP_ARPING(...)
#define CONFIG_FEATURE_UDHCPC_ARPING 1
#define ENABLE_FEATURE_UDHCPC_ARPING 1
#define USE_FEATURE_UDHCPC_ARPING(...) __VA_ARGS__
#define SKIP_FEATURE_UDHCPC_ARPING(...)

$ egrep _MMU applets/usage.c
./applets/usage.c:#define BB_MMU 0
./applets/usage.c:#define USE_FOR_MMU(...)
./applets/usage.c:#define BB_MMU 1
./applets/usage.c:#define USE_FOR_MMU(...) __VA_ARGS__

For consistancy, I would have expected something similar to this instead:
#define USE_BB_MMU(...) __VA_ARGS__
#define SKIP_BB_MMU(...)
...

Is applets/usage.c the best place?

Shouldn't this:

        USE_FEATURE_UDHCPC_ARPING(OPTBIT_a,)

be prefered, instead of this:

#if ENABLE_FEATURE_UDHCPC_ARPING
        OPTBIT_a,
#endif

The attchment shows how networking/udhcp/dhcpc.c may be changed.


Cheers,

-- 
Cristian
--- networking/udhcp/dhcpc.c.~1~	2008-06-14 19:37:37.000000000 +0200
+++ networking/udhcp/dhcpc.c	2008-06-14 20:24:20.000000000 +0200
@@ -169,12 +169,8 @@
 		"no-default-options\0" No_argument   "o"
 		"foreground\0"     No_argument       "f"
 		"background\0"     No_argument       "b"
-#if ENABLE_FEATURE_UDHCPC_ARPING
-		"arping\0"         No_argument       "a"
-#endif
-#if ENABLE_FEATURE_UDHCP_PORT
-		"client-port\0"	   Required_argument "P"
-#endif
+		USE_FEATURE_UDHCPC_ARPING("arping\0"	No_argument       "a")
+		USE_FEATURE_UDHCP_PORT("client-port\0"	Required_argument "P")
 		;
 #endif
 	enum {
@@ -201,40 +197,26 @@
 		OPT_f = 1 << 20,
 /* The rest has variable bit positions, need to be clever */
 		OPTBIT_f = 20,
-#if BB_MMU
-		OPTBIT_b,
-#endif
-#if ENABLE_FEATURE_UDHCPC_ARPING
-		OPTBIT_a,
-#endif
-#if ENABLE_FEATURE_UDHCP_PORT
-		OPTBIT_P,
-#endif
-#if BB_MMU
-		OPT_b = 1 << OPTBIT_b,
-#endif
-#if ENABLE_FEATURE_UDHCPC_ARPING
-		OPT_a = 1 << OPTBIT_a,
-#endif
-#if ENABLE_FEATURE_UDHCP_PORT
-		OPT_P = 1 << OPTBIT_P,
-#endif
+		USE_FOR_MMU(OPTBIT_b,)
+		USE_FEATURE_UDHCPC_ARPING(OPTBIT_a,)
+		USE_FEATURE_UDHCP_PORT(OPTBIT_P,)
+		USE_FOR_MMU(OPT_b = 1 << OPTBIT_b,)
+		USE_FEATURE_UDHCPC_ARPING(OPT_a = 1 << OPTBIT_a,)
+		USE_FEATURE_UDHCP_PORT(OPT_P = 1 << OPTBIT_P,)
 	};
 
 	/* Default options. */
-#if ENABLE_FEATURE_UDHCP_PORT
-	SERVER_PORT = 67;
-	CLIENT_PORT = 68;
-#endif
+	USE_FEATURE_UDHCP_PORT(
+		SERVER_PORT = 67;
+		CLIENT_PORT = 68;
+	)
 	client_config.interface = "eth0";
 	client_config.script = DEFAULT_SCRIPT;
 
 	/* Parse command line */
 	/* Cc: mutually exclusive; O: list; -T,-t,-A take numeric param */
 	opt_complementary = "c--C:C--c:O::T+:t+:A+";
-#if ENABLE_GETOPT_LONG
-	applet_long_options = udhcpc_longopts;
-#endif
+	USE_GETOPT_LONG(applet_long_options = udhcpc_longopts;)
 	opt = getopt32(argv, "c:CV:H:h:F:i:np:qRr:s:T:t:vSA:O:of"
 		USE_FOR_MMU("b")
 		USE_FEATURE_UDHCPC_ARPING("a")
@@ -270,12 +252,12 @@
 		puts("version "BB_VER);
 		return 0;
 	}
-#if ENABLE_FEATURE_UDHCP_PORT
-	if (opt & OPT_P) {
-		CLIENT_PORT = xatou16(str_P);
-		SERVER_PORT = CLIENT_PORT - 1;
-	}
-#endif
+	USE_FEATURE_UDHCP_PORT(
+		if (opt & OPT_P) {
+			CLIENT_PORT = xatou16(str_P);
+			SERVER_PORT = CLIENT_PORT - 1;
+		}
+	)
 	if (opt & OPT_o)
 		client_config.no_default_options = 1;
 	while (list_O) {
@@ -543,7 +525,7 @@
 						if (lease_seconds < 10) /* and not too small */
 							lease_seconds = 10;
 					}
-#if ENABLE_FEATURE_UDHCPC_ARPING
+					USE_FEATURE_UDHCPC_ARPING(
 					if (opt & OPT_a) {
 						if (!arpping(packet.yiaddr,
 							    (uint32_t) 0,
@@ -565,7 +547,7 @@
 							continue; /* back to main loop */
 						}
 					}
-#endif
+					)
 					/* enter bound state */
 					timeout = lease_seconds / 2;
 					{
_______________________________________________
busybox mailing list
[email protected]
http://busybox.net/cgi-bin/mailman/listinfo/busybox

Reply via email to