summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Vlasenko2008-05-31 07:33:18 +0000
committerDenis Vlasenko2008-05-31 07:33:18 +0000
commit3e57adb73198874b3924cb9aa8770193c894b1a9 (patch)
treeed9aac14a4c4f1b521a60fb7aa2428afaf255111
parent8f74094548a1147ed7b459ca771343483b1c202c (diff)
downloadbusybox-3e57adb73198874b3924cb9aa8770193c894b1a9.zip
busybox-3e57adb73198874b3924cb9aa8770193c894b1a9.tar.gz
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 044538a..b3cbe38 100644
--- a/networking/libiproute/ipaddress.c
+++ b/networking/libiproute/ipaddress.c
@@ -10,8 +10,6 @@
* Laszlo Valko <valko@linux.karinthy.hu> 990223: address label must be zero terminated
*/
-//#include <sys/socket.h>
-//#include <sys/ioctl.h>
#include <fnmatch.h>
#include <net/if.h>
#include <net/if_arp.h>
@@ -22,20 +20,20 @@
typedef struct filter_t {
- int ifindex;
- int family;
- int oneline;
- int showqueue;
- inet_prefix pfx;
- int scope, scopemask;
- int flags, flagmask;
- int up;
char *label;
- int flushed;
char *flushb;
+ struct rtnl_handle *rth;
+ int scope, scopemask;
+ int flags, flagmask;
int flushp;
int flushe;
- struct rtnl_handle *rth;
+ int ifindex;
+ family_t family;
+ smallint showqueue;
+ smallint oneline;
+ smallint up;
+ smallint flushed;
+ inet_prefix pfx;
} filter_t;
#define filter (*(filter_t*)&bb_common_bufsiz1)
@@ -45,7 +43,7 @@ static void print_link_flags(FILE *fp, unsigned flags, unsigned mdown)
{
fprintf(fp, "<");
flags &= ~IFF_RUNNING;
-#define _PF(f) if (flags&IFF_##f) { \
+#define _PF(f) if (flags & IFF_##f) { \
flags &= ~IFF_##f; \
fprintf(fp, #f "%s", flags ? "," : ""); }
_PF(LOOPBACK);
@@ -112,7 +110,7 @@ static int print_linkinfo(struct sockaddr_nl ATTRIBUTE_UNUSED *who,
if (filter.ifindex && ifi->ifi_index != filter.ifindex)
return 0;
- if (filter.up && !(ifi->ifi_flags&IFF_UP))
+ if (filter.up && !(ifi->ifi_flags & IFF_UP))
return 0;
memset(tb, 0, sizeof(tb));
@@ -229,9 +227,9 @@ static int print_addrinfo(struct sockaddr_nl ATTRIBUTE_UNUSED *who,
if (filter.ifindex && filter.ifindex != ifa->ifa_index)
return 0;
- if ((filter.scope^ifa->ifa_scope)&filter.scopemask)
+ if ((filter.scope ^ ifa->ifa_scope) & filter.scopemask)
return 0;
- if ((filter.flags^ifa->ifa_flags)&filter.flagmask)
+ if ((filter.flags ^ ifa->ifa_flags) & filter.flagmask)
return 0;
if (filter.label) {
const char *label;
@@ -265,7 +263,7 @@ static int print_addrinfo(struct sockaddr_nl ATTRIBUTE_UNUSED *who,
fn->nlmsg_flags = NLM_F_REQUEST;
fn->nlmsg_seq = ++filter.rth->seq;
filter.flushp = (((char*)fn) + n->nlmsg_len) - filter.flushb;
- filter.flushed++;
+ filter.flushed = 1;
return 0;
}
@@ -315,19 +313,19 @@ static int print_addrinfo(struct sockaddr_nl ATTRIBUTE_UNUSED *who,
abuf, sizeof(abuf)));
}
fprintf(fp, "scope %s ", rtnl_rtscope_n2a(ifa->ifa_scope, b1, sizeof(b1)));
- if (ifa->ifa_flags&IFA_F_SECONDARY) {
+ if (ifa->ifa_flags & IFA_F_SECONDARY) {
ifa->ifa_flags &= ~IFA_F_SECONDARY;
fprintf(fp, "secondary ");
}
- if (ifa->ifa_flags&IFA_F_TENTATIVE) {
+ if (ifa->ifa_flags & IFA_F_TENTATIVE) {
ifa->ifa_flags &= ~IFA_F_TENTATIVE;
fprintf(fp, "tentative ");
}
- if (ifa->ifa_flags&IFA_F_DEPRECATED) {
+ if (ifa->ifa_flags & IFA_F_DEPRECATED) {
ifa->ifa_flags &= ~IFA_F_DEPRECATED;
fprintf(fp, "deprecated ");
}
- if (!(ifa->ifa_flags&IFA_F_PERMANENT)) {
+ if (!(ifa->ifa_flags & IFA_F_PERMANENT)) {
fprintf(fp, "dynamic ");
} else
ifa->ifa_flags &= ~IFA_F_PERMANENT;
@@ -396,7 +394,8 @@ static int store_nlmsg(struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
memcpy(&h->h, n, n->nlmsg_len);
h->next = NULL;
- for (lp = linfo; *lp; lp = &(*lp)->next) /* NOTHING */;
+ for (lp = linfo; *lp; lp = &(*lp)->next)
+ continue;
*lp = h;
ll_remember_index(who, n, NULL);
diff --git a/networking/libiproute/iproute.c b/networking/libiproute/iproute.c
index 670f188..1f64794 100644
--- a/networking/libiproute/iproute.c
+++ b/networking/libiproute/iproute.c
@@ -24,7 +24,7 @@
typedef struct filter_t {
int tb;
- int flushed;
+ smallint flushed;
char *flushb;
int flushp;
int flushe;
@@ -189,7 +189,7 @@ static int print_route(struct sockaddr_nl *who ATTRIBUTE_UNUSED,
fn->nlmsg_flags = NLM_F_REQUEST;
fn->nlmsg_seq = ++filter.rth->seq;
filter.flushp = (((char*)fn) + n->nlmsg_len) - filter.flushb;
- filter.flushed++;
+ filter.flushed = 1;
return 0;
}
diff --git a/networking/libiproute/utils.h b/networking/libiproute/utils.h
index b67619d..06b1f04 100644
--- a/networking/libiproute/utils.h
+++ b/networking/libiproute/utils.h
@@ -32,8 +32,7 @@ extern void incomplete_command(void) ATTRIBUTE_NORETURN;
#define NEXT_ARG() do { if (!*++argv) incomplete_command(); } while (0)
-typedef struct
-{
+typedef struct {
uint8_t family;
uint8_t bytelen;
int16_t bitlen;