ip: code cleanup
Run all the ip code through checkpatch and have it fix the obvious stuff.
diff --git a/ip/ipneigh.c b/ip/ipneigh.c
index 48cca19..6458c8e 100644
--- a/ip/ipneigh.c
+++ b/ip/ipneigh.c
@@ -31,7 +31,7 @@
static struct
{
int family;
- int index;
+ int index;
int state;
int unused_only;
inet_prefix pfx;
@@ -50,11 +50,11 @@
" { ADDR [ lladdr LLADDR ] [ nud STATE ] | proxy ADDR } [ dev DEV ]\n");
fprintf(stderr, " ip neigh { show | flush } [ proxy ] [ to PREFIX ] [ dev DEV ] [ nud STATE ]\n\n");
fprintf(stderr, "STATE := { permanent | noarp | stale | reachable | none |\n"
- " incomplete | delay | probe | failed }\n");
+ " incomplete | delay | probe | failed }\n");
exit(-1);
}
-static int nud_state_a2n(unsigned *state, const char *arg)
+static int nud_state_a2n(unsigned int *state, const char *arg)
{
if (matches(arg, "permanent") == 0)
*state = NUD_PERMANENT;
@@ -77,7 +77,7 @@
else {
if (get_unsigned(state, arg, 0))
return -1;
- if (*state>=0x100 || (*state&((*state)-1)))
+ if (*state >= 0x100 || (*state&((*state)-1)))
return -1;
}
return 0;
@@ -99,13 +99,13 @@
struct {
struct nlmsghdr n;
struct ndmsg ndm;
- char buf[256];
+ char buf[256];
} req;
char *dev = NULL;
int dst_ok = 0;
int dev_ok = 0;
int lladdr_ok = 0;
- char * lla = NULL;
+ char *lla = NULL;
inet_prefix dst;
memset(&req, 0, sizeof(req));
@@ -124,7 +124,8 @@
lla = *argv;
lladdr_ok = 1;
} else if (strcmp(*argv, "nud") == 0) {
- unsigned state;
+ unsigned int state;
+
NEXT_ARG();
if (nud_state_a2n(&state, *argv))
invarg("nud state is bad", *argv);
@@ -193,10 +194,10 @@
int print_neigh(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
{
- FILE *fp = (FILE*)arg;
+ FILE *fp = (FILE *)arg;
struct ndmsg *r = NLMSG_DATA(n);
int len = n->nlmsg_len;
- struct rtattr * tb[NDA_MAX+1];
+ struct rtattr *tb[NDA_MAX+1];
char abuf[256];
static int logit = 1;
@@ -223,7 +224,7 @@
if (!(filter.state&r->ndm_state) &&
!(r->ndm_flags & NTF_PROXY) &&
(r->ndm_state || !(filter.state&0x100)) &&
- (r->ndm_family != AF_DECnet))
+ (r->ndm_family != AF_DECnet))
return 0;
if (filter.master && !(n->nlmsg_flags & NLM_F_DUMP_FILTERED)) {
@@ -239,6 +240,7 @@
if (tb[NDA_DST]) {
if (filter.pfx.family) {
inet_prefix dst;
+
memset(&dst, 0, sizeof(dst));
dst.family = r->ndm_family;
memcpy(&dst.data, RTA_DATA(tb[NDA_DST]), RTA_PAYLOAD(tb[NDA_DST]));
@@ -248,22 +250,24 @@
}
if (filter.unused_only && tb[NDA_CACHEINFO]) {
struct nda_cacheinfo *ci = RTA_DATA(tb[NDA_CACHEINFO]);
+
if (ci->ndm_refcnt)
return 0;
}
if (filter.flushb) {
struct nlmsghdr *fn;
+
if (NLMSG_ALIGN(filter.flushp) + n->nlmsg_len > filter.flushe) {
if (flush_update())
return -1;
}
- fn = (struct nlmsghdr*)(filter.flushb + NLMSG_ALIGN(filter.flushp));
+ fn = (struct nlmsghdr *)(filter.flushb + NLMSG_ALIGN(filter.flushp));
memcpy(fn, n, n->nlmsg_len);
fn->nlmsg_type = RTM_DELNEIGH;
fn->nlmsg_flags = NLM_F_REQUEST;
fn->nlmsg_seq = ++rth.seq;
- filter.flushp = (((char*)fn) + n->nlmsg_len) - filter.flushb;
+ filter.flushp = (((char *)fn) + n->nlmsg_len) - filter.flushb;
filter.flushed++;
if (show_stats < 2)
return 0;
@@ -307,11 +311,13 @@
if (tb[NDA_PROBES] && show_stats) {
__u32 p = rta_getattr_u32(tb[NDA_PROBES]);
+
fprintf(fp, " probes %u", p);
}
if (r->ndm_state) {
int nud = r->ndm_state;
+
fprintf(fp, " ");
#define PRINT_FLAG(f) if (nud & NUD_##f) { \
@@ -344,7 +350,7 @@
struct {
struct nlmsghdr n;
struct ndmsg ndm;
- char buf[256];
+ char buf[256];
} req;
char *filter_dev = NULL;
int state_given = 0;
@@ -376,6 +382,7 @@
filter_dev = *argv;
} else if (strcmp(*argv, "master") == 0) {
int ifindex;
+
NEXT_ARG();
ifindex = ll_name_to_index(*argv);
if (!ifindex)
@@ -385,7 +392,8 @@
} else if (strcmp(*argv, "unused") == 0) {
filter.unused_only = 1;
} else if (strcmp(*argv, "nud") == 0) {
- unsigned state;
+ unsigned int state;
+
NEXT_ARG();
if (!state_given) {
state_given = 1;
@@ -450,7 +458,7 @@
if (round == 0)
printf("Nothing to flush.\n");
else
- printf("*** Flush is complete after %d round%s ***\n", round, round>1?"s":"");
+ printf("*** Flush is complete after %d round%s ***\n", round, round > 1?"s":"");
}
fflush(stdout);
return 0;