#ifdefectomy for editors/cmp.c

Rob Landley rob at landley.net
Sun Apr 25 19:43:06 UTC 2010


I'm not sure why cmp.c is an editor, but ok.

Turn #if ENABLE_DESKTOP preprocessor blocks into normal C code using if 
(ENABLE_DESKTOP) and let the compiler's dead code elimination drop out the 
code.

With ENABLE_DESKTOP switched off (both before and after), make bloatcheck 
reports no size change:

function                                             old     new   delta
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/0 up/down: 0/0)                 Total: 0 bytes

Posssibly for this block:

-       opt_complementary = "-1"
-                       IF_DESKTOP(":?4")
-                       IF_NOT_DESKTOP(":?2")
+       opt_complementary = "-1:?"IF_DESKTOP("4")IF_NOT_DESKTOP("2")

What we really need is some kind of IF_ELSE_DESKTOP("4","2").  It wouldn't be 
able to handle stuff with commas in it, but in cases like this it might be 
useful...

By the way, this block near the start:

/* Mar 16, 2003      Manuel Novoa III   (mjn3 at codepoet.org)
 *
 * Original version majorly reworked for SUSv3 compliance, bug fixes, and
 * size optimizations.  Changes include:
 * 1) Now correctly distinguishes between errors and actual file differences.
 * 2) Proper handling of '-' args.
 * 3) Actual error checking of i/o.
 * 4) Accept SUSv3 -l option.  Note that we use the slightly nicer gnu format
 *    in the '-l' case.
 */

Is really a repository comment, not something that belongs in the source.  
(What I'd do is have a separate commit that removes that, and the comment for 
the commit should have the complete text of the comment it's removing from the 
source.)

Denys: should I set up a git tree you can pull from for this sort of thing?  I 
vaguely plan to make some time to do random cleanups like this to get back up 
to speed on busybox development...

Rob
-- 
Latency is more important than throughput. It's that simple. - Linus Torvalds
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cmp-unifdef.patch
Type: text/x-patch
Size: 1489 bytes
Desc: not available
URL: <http://lists.busybox.net/pipermail/busybox/attachments/20100425/bb53019b/attachment-0001.bin>


More information about the busybox mailing list