mdev

Rob Landley rob at landley.net
Sat Apr 18 02:03:43 UTC 2009


On Thursday 16 April 2009 17:26:17 Denys Vlasenko wrote:
> On Wednesday 15 April 2009 01:02, Rob Landley wrote:
> > I started looking at your patch, then I started looking at the mdev.c
> > code it applies to, and...
> >
> > #if ENABLE_FEATURE_MDEV_CONF
> >         parser_t *parser;
> > #endif
> >
> > Unused stack variables should be optimized out by any half-competent
> > compiler.
>
> But compiler wouldn't warn me when I _use_ the variable outside of
> ENABLE_FEATURE_MDEV_CONF block by mistake. With the above ugly #if,
> I get compiler error in this case.

If you use it uninitialized, you get warned.  If you assign to it without 
using the value later, it gets optimized out.  And presumably you check the 
size with bloatcheck to figure out how much space you're using and look for 
savings...

*shrug*  Your codebase, not mine...

> > Wrapping the whole thing in if (ENABLE_FEATURE_MDEV_RENAME) {
> > accomplishes the same purpose without having the preprocessor chop up the
> > code...
> >
> > The whole file is like this now...
>
> We have different coding style.

I noticed.

> I am not against your style, I just am not adopting yours as mine,
> just like I do not expect you to adopt my style.
>
> Please send a patch which reduces #ifdef forest
> along with make bloatcheck output which shows that
> there is no code difference (apart from gcc noise of +/-10 bytes),
> and I'll be happy to apply it.

*shrug*  I've got half an hour, sure.

Attached.

function                                             old     new   delta
make_device                                         1499    1496      -3
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-3)               Total: -3 bytes
   text    data     bss     dec     hex filename
 888845    4300   10048  903193   dc819 busybox_old
 888842    4300   10048  903190   dc816 busybox_unstripped

Lots of noise due to changing indentation levels.  (When I turned #if into an 
actual if() {} I indented it properly.)

The only actual change to the code was the bit where I cleaned up the $@* 
matching slightly.  (Saved 3 bytes and made the resulting code clearer, 
couldn't resist.) 

I also reordered a couple of variable declarations on the stack so the 
compiler can more easily optimize out unused stack variables, which modern 
gcc probably doesn't need and only nommu people would ever really notice 
anyway, since these aren't particularly recursive functions or big 
structures, that I know of...

Rob
-- 
Latency is more important than throughput. It's that simple. - Linus Torvalds
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mdev-ifdefectomy.patch
Type: text/x-diff
Size: 11506 bytes
Desc: not available
URL: <http://lists.busybox.net/pipermail/busybox/attachments/20090417/0d070489/attachment.bin>


More information about the busybox mailing list