On Sun, 15 Jun 2008, Bernhard Fischer wrote:

> >> USE_IF_FEATURE_X and SKIP_IF_FEATURE_X would be better.
>
> I don't think explicitely adding the implied "_IF" buys anything.

True.  Costs 3 extra characters, but makes more obvious what the macro is
supposed to do.

> I disagree. There is USE_ and SKIP_ that use varargs. For bigger blocks
> or where it is more readable, there is ENABLE and !ENABLE

Not always possible (without doing more changes).  The attachment is a POC
for a ifdef free networking/udhcp/dhcpc.c (skipped indentation whitespace
for clarity).


Cheers,

-- 
Cristian
Index: networking/udhcp/dhcpc.c
===================================================================
--- networking/udhcp/dhcpc.c	(revision 22350)
+++ networking/udhcp/dhcpc.c	(working copy)
@@ -146,7 +146,7 @@
 	struct dhcpMessage packet;
 	fd_set rfds;
 
-#if ENABLE_GETOPT_LONG
+	USE_GETOPT_LONG(
 	static const char udhcpc_longopts[] ALIGN1 =
 		"clientid\0"       Required_argument "c"
 		"clientid-none\0"  No_argument       "C"
@@ -172,7 +172,7 @@
 		USE_FEATURE_UDHCPC_ARPING("arping\0"	No_argument       "a")
 		USE_FEATURE_UDHCP_PORT("client-port\0"	Required_argument "P")
 		;
-#endif
+	)
 	enum {
 		OPT_c = 1 << 0,
 		OPT_C = 1 << 1,
@@ -250,12 +250,12 @@
 		puts("version "BB_VER);
 		return 0;
 	}
-#if ENABLE_FEATURE_UDHCP_PORT
+	USE_FEATURE_UDHCP_PORT(
 	if (opt & OPT_P) {
 		CLIENT_PORT = xatou16(str_P);
 		SERVER_PORT = CLIENT_PORT - 1;
 	}
-#endif
+	)
 	if (opt & OPT_o)
 		client_config.no_default_options = 1;
 	while (list_O) {
@@ -269,13 +269,13 @@
 	if (read_interface(client_config.interface, &client_config.ifindex,
 			   NULL, client_config.arp))
 		return 1;
-#if !BB_MMU
+	if (!BB_MMU) {
 	/* on NOMMU reexec (i.e., background) early */
 	if (!(opt & OPT_f)) {
 		bb_daemonize_or_rexec(0 /* flags */, argv);
 		logmode = 0;
 	}
-#endif
+	}
 	if (opt & OPT_S) {
 		openlog(applet_name, LOG_PID, LOG_LOCAL0);
 		logmode |= LOGMODE_SYSLOG;
@@ -522,7 +522,7 @@
 						if (lease_seconds < 10) /* and not too small */
 							lease_seconds = 10;
 					}
-#if ENABLE_FEATURE_UDHCPC_ARPING
+					if (ENABLE_FEATURE_UDHCPC_ARPING) {
 					if (opt & OPT_a) {
 						if (!arpping(packet.yiaddr,
 							    (uint32_t) 0,
@@ -544,7 +544,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