aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2008-05-31 07:33:18 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2008-05-31 07:33:18 +0000
commit3e57adb73198874b3924cb9aa8770193c894b1a9 (patch)
treeed9aac14a4c4f1b521a60fb7aa2428afaf255111
parent8f74094548a1147ed7b459ca771343483b1c202c (diff)
downloadbusybox-w32-3e57adb73198874b3924cb9aa8770193c894b1a9.tar.gz
busybox-w32-3e57adb73198874b3924cb9aa8770193c894b1a9.tar.bz2
busybox-w32-3e57adb73198874b3924cb9aa8770193c894b1a9.zip
libiproute: style fixes, and using smallint as appropriate
function old new delta print_route 1730 1731 +1 print_addrinfo 1497 1498 +1 iproute_list_or_flush 1232 1229 -3 ipaddr_list_or_flush 2490 2484 -6 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/2 up/down: 2/-9) Total: -7 bytes
-rw-r--r--networking/libiproute/ipaddress.c43
-rw-r--r--networking/libiproute/iproute.c4
-rw-r--r--networking/libiproute/utils.h3
3 files changed, 24 insertions, 26 deletions
diff --git a/networking/libiproute/ipaddress.c b/networking/libiproute/ipaddress.c
index 044538aca..b3cbe3840 100644
--- a/networking/libiproute/ipaddress.c
+++ b/networking/libiproute/ipaddress.c
@@ -10,8 +10,6 @@
10 * Laszlo Valko <valko@linux.karinthy.hu> 990223: address label must be zero terminated 10 * Laszlo Valko <valko@linux.karinthy.hu> 990223: address label must be zero terminated
11 */ 11 */
12 12
13//#include <sys/socket.h>
14//#include <sys/ioctl.h>
15#include <fnmatch.h> 13#include <fnmatch.h>
16#include <net/if.h> 14#include <net/if.h>
17#include <net/if_arp.h> 15#include <net/if_arp.h>
@@ -22,20 +20,20 @@
22 20
23 21
24typedef struct filter_t { 22typedef struct filter_t {
25 int ifindex;
26 int family;
27 int oneline;
28 int showqueue;
29 inet_prefix pfx;
30 int scope, scopemask;
31 int flags, flagmask;
32 int up;
33 char *label; 23 char *label;
34 int flushed;
35 char *flushb; 24 char *flushb;
25 struct rtnl_handle *rth;
26 int scope, scopemask;
27 int flags, flagmask;
36 int flushp; 28 int flushp;
37 int flushe; 29 int flushe;
38 struct rtnl_handle *rth; 30 int ifindex;
31 family_t family;
32 smallint showqueue;
33 smallint oneline;
34 smallint up;
35 smallint flushed;
36 inet_prefix pfx;
39} filter_t; 37} filter_t;
40 38
41#define filter (*(filter_t*)&bb_common_bufsiz1) 39#define filter (*(filter_t*)&bb_common_bufsiz1)
@@ -45,7 +43,7 @@ static void print_link_flags(FILE *fp, unsigned flags, unsigned mdown)
45{ 43{
46 fprintf(fp, "<"); 44 fprintf(fp, "<");
47 flags &= ~IFF_RUNNING; 45 flags &= ~IFF_RUNNING;
48#define _PF(f) if (flags&IFF_##f) { \ 46#define _PF(f) if (flags & IFF_##f) { \
49 flags &= ~IFF_##f; \ 47 flags &= ~IFF_##f; \
50 fprintf(fp, #f "%s", flags ? "," : ""); } 48 fprintf(fp, #f "%s", flags ? "," : ""); }
51 _PF(LOOPBACK); 49 _PF(LOOPBACK);
@@ -112,7 +110,7 @@ static int print_linkinfo(struct sockaddr_nl ATTRIBUTE_UNUSED *who,
112 110
113 if (filter.ifindex && ifi->ifi_index != filter.ifindex) 111 if (filter.ifindex && ifi->ifi_index != filter.ifindex)
114 return 0; 112 return 0;
115 if (filter.up && !(ifi->ifi_flags&IFF_UP)) 113 if (filter.up && !(ifi->ifi_flags & IFF_UP))
116 return 0; 114 return 0;
117 115
118 memset(tb, 0, sizeof(tb)); 116 memset(tb, 0, sizeof(tb));
@@ -229,9 +227,9 @@ static int print_addrinfo(struct sockaddr_nl ATTRIBUTE_UNUSED *who,
229 227
230 if (filter.ifindex && filter.ifindex != ifa->ifa_index) 228 if (filter.ifindex && filter.ifindex != ifa->ifa_index)
231 return 0; 229 return 0;
232 if ((filter.scope^ifa->ifa_scope)&filter.scopemask) 230 if ((filter.scope ^ ifa->ifa_scope) & filter.scopemask)
233 return 0; 231 return 0;
234 if ((filter.flags^ifa->ifa_flags)&filter.flagmask) 232 if ((filter.flags ^ ifa->ifa_flags) & filter.flagmask)
235 return 0; 233 return 0;
236 if (filter.label) { 234 if (filter.label) {
237 const char *label; 235 const char *label;
@@ -265,7 +263,7 @@ static int print_addrinfo(struct sockaddr_nl ATTRIBUTE_UNUSED *who,
265 fn->nlmsg_flags = NLM_F_REQUEST; 263 fn->nlmsg_flags = NLM_F_REQUEST;
266 fn->nlmsg_seq = ++filter.rth->seq; 264 fn->nlmsg_seq = ++filter.rth->seq;
267 filter.flushp = (((char*)fn) + n->nlmsg_len) - filter.flushb; 265 filter.flushp = (((char*)fn) + n->nlmsg_len) - filter.flushb;
268 filter.flushed++; 266 filter.flushed = 1;
269 return 0; 267 return 0;
270 } 268 }
271 269
@@ -315,19 +313,19 @@ static int print_addrinfo(struct sockaddr_nl ATTRIBUTE_UNUSED *who,
315 abuf, sizeof(abuf))); 313 abuf, sizeof(abuf)));
316 } 314 }
317 fprintf(fp, "scope %s ", rtnl_rtscope_n2a(ifa->ifa_scope, b1, sizeof(b1))); 315 fprintf(fp, "scope %s ", rtnl_rtscope_n2a(ifa->ifa_scope, b1, sizeof(b1)));
318 if (ifa->ifa_flags&IFA_F_SECONDARY) { 316 if (ifa->ifa_flags & IFA_F_SECONDARY) {
319 ifa->ifa_flags &= ~IFA_F_SECONDARY; 317 ifa->ifa_flags &= ~IFA_F_SECONDARY;
320 fprintf(fp, "secondary "); 318 fprintf(fp, "secondary ");
321 } 319 }
322 if (ifa->ifa_flags&IFA_F_TENTATIVE) { 320 if (ifa->ifa_flags & IFA_F_TENTATIVE) {
323 ifa->ifa_flags &= ~IFA_F_TENTATIVE; 321 ifa->ifa_flags &= ~IFA_F_TENTATIVE;
324 fprintf(fp, "tentative "); 322 fprintf(fp, "tentative ");
325 } 323 }
326 if (ifa->ifa_flags&IFA_F_DEPRECATED) { 324 if (ifa->ifa_flags & IFA_F_DEPRECATED) {
327 ifa->ifa_flags &= ~IFA_F_DEPRECATED; 325 ifa->ifa_flags &= ~IFA_F_DEPRECATED;
328 fprintf(fp, "deprecated "); 326 fprintf(fp, "deprecated ");
329 } 327 }
330 if (!(ifa->ifa_flags&IFA_F_PERMANENT)) { 328 if (!(ifa->ifa_flags & IFA_F_PERMANENT)) {
331 fprintf(fp, "dynamic "); 329 fprintf(fp, "dynamic ");
332 } else 330 } else
333 ifa->ifa_flags &= ~IFA_F_PERMANENT; 331 ifa->ifa_flags &= ~IFA_F_PERMANENT;
@@ -396,7 +394,8 @@ static int store_nlmsg(struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
396 memcpy(&h->h, n, n->nlmsg_len); 394 memcpy(&h->h, n, n->nlmsg_len);
397 h->next = NULL; 395 h->next = NULL;
398 396
399 for (lp = linfo; *lp; lp = &(*lp)->next) /* NOTHING */; 397 for (lp = linfo; *lp; lp = &(*lp)->next)
398 continue;
400 *lp = h; 399 *lp = h;
401 400
402 ll_remember_index(who, n, NULL); 401 ll_remember_index(who, n, NULL);
diff --git a/networking/libiproute/iproute.c b/networking/libiproute/iproute.c
index 670f188ee..1f6479454 100644
--- a/networking/libiproute/iproute.c
+++ b/networking/libiproute/iproute.c
@@ -24,7 +24,7 @@
24 24
25typedef struct filter_t { 25typedef struct filter_t {
26 int tb; 26 int tb;
27 int flushed; 27 smallint flushed;
28 char *flushb; 28 char *flushb;
29 int flushp; 29 int flushp;
30 int flushe; 30 int flushe;
@@ -189,7 +189,7 @@ static int print_route(struct sockaddr_nl *who ATTRIBUTE_UNUSED,
189 fn->nlmsg_flags = NLM_F_REQUEST; 189 fn->nlmsg_flags = NLM_F_REQUEST;
190 fn->nlmsg_seq = ++filter.rth->seq; 190 fn->nlmsg_seq = ++filter.rth->seq;
191 filter.flushp = (((char*)fn) + n->nlmsg_len) - filter.flushb; 191 filter.flushp = (((char*)fn) + n->nlmsg_len) - filter.flushb;
192 filter.flushed++; 192 filter.flushed = 1;
193 return 0; 193 return 0;
194 } 194 }
195 195
diff --git a/networking/libiproute/utils.h b/networking/libiproute/utils.h
index b67619d20..06b1f04ab 100644
--- a/networking/libiproute/utils.h
+++ b/networking/libiproute/utils.h
@@ -32,8 +32,7 @@ extern void incomplete_command(void) ATTRIBUTE_NORETURN;
32 32
33#define NEXT_ARG() do { if (!*++argv) incomplete_command(); } while (0) 33#define NEXT_ARG() do { if (!*++argv) incomplete_command(); } while (0)
34 34
35typedef struct 35typedef struct {
36{
37 uint8_t family; 36 uint8_t family;
38 uint8_t bytelen; 37 uint8_t bytelen;
39 int16_t bitlen; 38 int16_t bitlen;