aboutsummaryrefslogtreecommitdiff
path: root/networking
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2007-07-29 14:17:48 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2007-07-29 14:17:48 +0000
commit6b74b0241cd22d4bdef1ef1860c19565fdbc4e9c (patch)
tree981aecc3eaad2b20f7f4c6c077a08f427035ceda /networking
parentdee82b6b78fab258584414557915e5169b051665 (diff)
downloadbusybox-6b74b0241cd22d4bdef1ef1860c19565fdbc4e9c.tar.gz
interface.c: code shrink (IIRC ~30 bytes)
Diffstat (limited to 'networking')
-rw-r--r--networking/interface.c86
1 files changed, 43 insertions, 43 deletions
diff --git a/networking/interface.c b/networking/interface.c
index 92d7f5dc0..9e6ed63e0 100644
--- a/networking/interface.c
+++ b/networking/interface.c
@@ -896,45 +896,6 @@ static void print_bytes_scaled(unsigned long long ull, const char *end)
printf("X bytes:%llu (%llu.%u %sB)%s", ull, int_part, frac_part, ext, end);
}
-static const char *const ife_print_flags_strs[] = {
- "UP ",
- "BROADCAST ",
- "DEBUG ",
- "LOOPBACK ",
- "POINTOPOINT ",
- "NOTRAILERS ",
- "RUNNING ",
- "NOARP ",
- "PROMISC ",
- "ALLMULTI ",
- "SLAVE ",
- "MASTER ",
- "MULTICAST ",
-#ifdef HAVE_DYNAMIC
- "DYNAMIC "
-#endif
-};
-
-static const unsigned short ife_print_flags_mask[] = {
- IFF_UP,
- IFF_BROADCAST,
- IFF_DEBUG,
- IFF_LOOPBACK,
- IFF_POINTOPOINT,
- IFF_NOTRAILERS,
- IFF_RUNNING,
- IFF_NOARP,
- IFF_PROMISC,
- IFF_ALLMULTI,
- IFF_SLAVE,
- IFF_MASTER,
- IFF_MULTICAST,
-#ifdef HAVE_DYNAMIC
- IFF_DYNAMIC
-#endif
- 0
-};
-
static void ife_print(struct interface *ptr)
{
const struct aftype *ap;
@@ -1059,12 +1020,51 @@ static void ife_print(struct interface *ptr)
if (ptr->flags == 0) {
printf("[NO FLAGS] ");
} else {
- int i = 0;
+ static const char ife_print_flags_strs[] =
+ "UP\0"
+ "BROADCAST\0"
+ "DEBUG\0"
+ "LOOPBACK\0"
+ "POINTOPOINT\0"
+ "NOTRAILERS\0"
+ "RUNNING\0"
+ "NOARP\0"
+ "PROMISC\0"
+ "ALLMULTI\0"
+ "SLAVE\0"
+ "MASTER\0"
+ "MULTICAST\0"
+#ifdef HAVE_DYNAMIC
+ "DYNAMIC\0"
+#endif
+ ;
+ static const unsigned short ife_print_flags_mask[] = {
+ IFF_UP,
+ IFF_BROADCAST,
+ IFF_DEBUG,
+ IFF_LOOPBACK,
+ IFF_POINTOPOINT,
+ IFF_NOTRAILERS,
+ IFF_RUNNING,
+ IFF_NOARP,
+ IFF_PROMISC,
+ IFF_ALLMULTI,
+ IFF_SLAVE,
+ IFF_MASTER,
+ IFF_MULTICAST,
+#ifdef HAVE_DYNAMIC
+ IFF_DYNAMIC,
+#endif
+ };
+ const unsigned short *mask = ife_print_flags_mask;
+ const char *str = ife_print_flags_strs;
do {
- if (ptr->flags & ife_print_flags_mask[i]) {
- printf(ife_print_flags_strs[i]);
+ if (ptr->flags & *mask) {
+ printf("%s ", str);
}
- } while (ife_print_flags_mask[++i]);
+ mask++;
+ str += strlen(str) + 1;
+ } while (*str);
}
/* DONT FORGET TO ADD THE FLAGS IN ife_print_short */