On Fri, Jun 06, 2008 at 01:39:15PM +0200, Natanael Copa wrote:
>Hi,
>
>I have looked more at the print_flags() I started with yesterday.
>
>Attatched are some patches and they should probably be committed to svn
>separatly (easier to revert in case they have bugs).
>
>I tried to use print_flags() in arp.c and fdisk.c but they seemed to
>increase the size so I chosed to not included them here. (ping me if
>someone want to take a look at them anyway)
>
>Patches are rebased from svn trunk this morning.
>
>Bloatcheck on hardened uclibc gcc-3.4.6:
>
>function                                             old     new   delta
>hdparm_main                                         1067    4916   +3849
>print_flags                                            -     135    +135
>static.ultra_modes2                                    -      88     +88
>static.dma_mword_modes                                 -      72     +72
>static.dma_1word_modes                                 -      72     +72
>static.ultra_modes1                                    -      56     +56
>static.link_flags                                      -      56     +56
>static.pio_modes                                       -      32     +32
>static.dflags                                          -      32     +32
>.rodata                                            31784   31770     -14
>xbsd_print_disklabel                                 927     892     -35
>ipaddr_list_or_flush                                2732    2455    -277
>process_dev                                         4446       -   -4446
>------------------------------------------------------------------------------
>(add/remove: 8/1 grow/shrink: 1/3 up/down: 4392/-4772)       Total: -380
>bytes
>   text           data     bss     dec     hex filename
> 135156           2173    4500  141829   22a05 busybox_old
> 134728           2677    4500  141905   22a51 busybox_unstripped
>
>-nc

>Index: libbb/print_flags.c
>===================================================================
>--- libbb/print_flags.c        (revision 0)
>+++ libbb/print_flags.c        (revision 0)
>@@ -0,0 +1,26 @@
>+/* vi: set sw=4 ts=4: */
>+/* Print string that matches bit masked flags
>+ *
>+ * Copyright (C) 2008 Natanael Copa <[EMAIL PROTECTED]>
>+ *
>+ * Licensed under GPLv2 or later, see file LICENSE in this tarball for 
>details.
>+ */
>+
>+#include <libbb.h>
>+
>+/* returns a set with the flags not printed */
>+int print_flags(const struct mask_string *ms, int flags, const char 
>*separator)
>+{
->+     int need_separator = 0;

and pass NULL instead of "", or rename this func to
print_flags_separated(mask_string_t, int, const char *const) and for the
NULL cases add a wrapper
int print_flags(const mask_string_t *ms, int flags) {
        return print_flags_separated(ms, flags, NULL);
}

>+      while (ms->string) {

I think it would be better (not sure if it would help that much,
admittedly) to have the strings 0 separated like we do with
index_in_strings and do something correspondingly with the flags.
>Index: include/libbb.h
>===================================================================
>--- include/libbb.h    (revision 22223)
>+++ include/libbb.h    (working copy)
>@@ -1304,7 +1304,14 @@
> /* "sh" */
> #define DEFAULT_SHELL_SHORT_NAME     (bb_default_login_shell+6)
> 
>+struct mask_string {
>+      int mask;
>+      const char *string;
>+};

typedef this, please.
> 
>+extern int print_flags(const struct mask_string *ms, int flags, const char 
>*separator);

bunch of const missing.

IIRC networking/{,*/}* has several occurances of that pattern, too, just
as a sidenote.
_______________________________________________
busybox mailing list
[email protected]
http://busybox.net/cgi-bin/mailman/listinfo/busybox

Reply via email to