ENABLE_DESKTOP in procps/ps.c

Cristian Ionescu-Idbohrn cristian.ionescu-idbohrn at axis.com
Sun Sep 5 12:34:42 UTC 2010


I've added comments (wrt ENABLE_DESKTOP) on each preprocessor line missing
one and grepped.  I see this:

17:#if ENABLE_DESKTOP
	341:#if ENABLE_DESKTOP
	344:#endif /* ENABLE_DESKTOP */
	349:#if ENABLE_DESKTOP
	351:#endif /* ENABLE_DESKTOP */
	353:#if ENABLE_DESKTOP
	356:#else /* !ENABLE_DESKTOP */
	358:#endif /* ENABLE_DESKTOP */
549:#else /* !ENABLE_DESKTOP */
641:#endif /* ENABLE_DESKTOP */

Above shows ENABLE_DESKTOP is uselessly making redundant checks on
something already known.  Cleanup patch:

diff --git a/procps/ps.c b/procps/ps.c
index 305381e..48b55a7 100644
--- a/procps/ps.c
+++ b/procps/ps.c
@@ -338,24 +338,16 @@ static ps_out_t* new_out_t(void)
 static const ps_out_t* find_out_spec(const char *name)
 {
 	unsigned i;
-#if ENABLE_DESKTOP
 	char buf[ARRAY_SIZE(out_spec)*7 + 1];
 	char *p = buf;
-#endif

 	for (i = 0; i < ARRAY_SIZE(out_spec); i++) {
 		if (strncmp(name, out_spec[i].name6, 6) == 0)
 			return &out_spec[i];
-#if ENABLE_DESKTOP
 		p += sprintf(p, "%.6s,", out_spec[i].name6);
-#endif
 	}
-#if ENABLE_DESKTOP
 	p[-1] = '\0';
 	bb_error_msg_and_die("bad -o argument '%s', supported arguments: %s", name, buf);
-#else
-	bb_error_msg_and_die("bad -o argument '%s'");
-#endif
 }

 static void parse_o(char* opt)


Cheers,

-- 
Cristian


More information about the busybox mailing list