Commit df4b043f authored by Stephen Hemminger's avatar Stephen Hemminger

bridge: code cleanup

Use checkpatch auto fix to cleanup lingering style issues
parent 56f5daac
......@@ -34,12 +34,12 @@ static void usage(void)
fprintf(stderr, "Usage: bridge fdb { add | append | del | replace } ADDR dev DEV\n"
" [ self ] [ master ] [ use ] [ router ]\n"
" [ local | static | dynamic ] [ dst IPADDR ] [ vlan VID ]\n"
" [ port PORT] [ vni VNI ] [ via DEV ]\n");
" [ port PORT] [ vni VNI ] [ via DEV ]\n");
fprintf(stderr, " bridge fdb [ show [ br BRDEV ] [ brport DEV ] ]\n");
exit(-1);
}
static const char *state_n2a(unsigned s)
static const char *state_n2a(unsigned int s)
{
static char buf[32];
......@@ -64,7 +64,7 @@ int print_fdb(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
FILE *fp = arg;
struct ndmsg *r = NLMSG_DATA(n);
int len = n->nlmsg_len;
struct rtattr * tb[NDA_MAX+1];
struct rtattr *tb[NDA_MAX+1];
if (n->nlmsg_type != RTM_NEWNEIGH && n->nlmsg_type != RTM_DELNEIGH) {
fprintf(stderr, "Not RTM_NEWNEIGH: %08x %08x %08x\n",
......@@ -119,6 +119,7 @@ int print_fdb(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
if (tb[NDA_VLAN]) {
__u16 vid = rta_getattr_u16(tb[NDA_VLAN]);
fprintf(fp, "vlan %hu ", vid);
}
......@@ -171,9 +172,9 @@ int print_fdb(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
static int fdb_show(int argc, char **argv)
{
struct {
struct nlmsghdr n;
struct nlmsghdr n;
struct ifinfomsg ifm;
char buf[256];
char buf[256];
} req;
char *filter_dev = NULL;
......@@ -200,6 +201,7 @@ static int fdb_show(int argc, char **argv)
if (br) {
int br_ifindex = ll_name_to_index(br);
if (br_ifindex == 0) {
fprintf(stderr, "Cannot find bridge device \"%s\"\n", br);
return -1;
......@@ -235,9 +237,9 @@ static int fdb_show(int argc, char **argv)
static int fdb_modify(int cmd, int flags, int argc, char **argv)
{
struct {
struct nlmsghdr n;
struct ndmsg ndm;
char buf[256];
struct nlmsghdr n;
struct ndmsg ndm;
char buf[256];
} req;
char *addr = NULL;
char *d = NULL;
......@@ -298,7 +300,7 @@ static int fdb_modify(int cmd, int flags, int argc, char **argv)
req.ndm.ndm_flags |= NTF_MASTER;
} else if (matches(*argv, "router") == 0) {
req.ndm.ndm_flags |= NTF_ROUTER;
} else if (matches(*argv, "local") == 0||
} else if (matches(*argv, "local") == 0 ||
matches(*argv, "permanent") == 0) {
req.ndm.ndm_state |= NUD_PERMANENT;
} else if (matches(*argv, "temp") == 0 ||
......
......@@ -25,17 +25,17 @@ static const char *port_states[] = {
[BR_STATE_BLOCKING] = "blocking",
};
extern char *if_indextoname (unsigned int __ifindex, char *__ifname);
extern char *if_indextoname(unsigned int __ifindex, char *__ifname);
static void print_link_flags(FILE *fp, unsigned flags)
static void print_link_flags(FILE *fp, unsigned int flags)
{
fprintf(fp, "<");
if (flags & IFF_UP && !(flags & IFF_RUNNING))
fprintf(fp, "NO-CARRIER%s", flags ? "," : "");
flags &= ~IFF_RUNNING;
#define _PF(f) if (flags&IFF_##f) { \
flags &= ~IFF_##f ; \
fprintf(fp, #f "%s", flags ? "," : ""); }
flags &= ~IFF_##f ; \
fprintf(fp, #f "%s", flags ? "," : ""); }
_PF(LOOPBACK);
_PF(BROADCAST);
_PF(POINTOPOINT);
......@@ -55,7 +55,7 @@ static void print_link_flags(FILE *fp, unsigned flags)
_PF(DORMANT);
_PF(ECHO);
#undef _PF
if (flags)
if (flags)
fprintf(fp, "%x", flags);
fprintf(fp, "> ");
}
......@@ -69,7 +69,7 @@ static const char *hw_mode[] = {"VEB", "VEPA"};
static void print_operstate(FILE *f, __u8 state)
{
if (state >= sizeof(oper_states)/sizeof(oper_states[0]))
if (state >= ARRAY_SIZE(oper_states))
fprintf(f, "state %#x ", state);
else
fprintf(f, "state %s ", oper_states[state]);
......@@ -90,7 +90,7 @@ static void print_onoff(FILE *f, char *flag, __u8 val)
static void print_hwmode(FILE *f, __u16 mode)
{
if (mode >= sizeof(hw_mode)/sizeof(hw_mode[0]))
if (mode >= ARRAY_SIZE(hw_mode))
fprintf(f, "hwmode %#hx ", mode);
else
fprintf(f, "hwmode %s ", hw_mode[mode]);
......@@ -102,14 +102,14 @@ int print_linkinfo(const struct sockaddr_nl *who,
FILE *fp = arg;
int len = n->nlmsg_len;
struct ifinfomsg *ifi = NLMSG_DATA(n);
struct rtattr * tb[IFLA_MAX+1];
struct rtattr *tb[IFLA_MAX+1];
char b1[IFNAMSIZ];
len -= NLMSG_LENGTH(sizeof(*ifi));
if (len < 0) {
fprintf(stderr, "Message too short!\n");
return -1;
}
}
if (!(ifi->ifi_family == AF_BRIDGE || ifi->ifi_family == AF_UNSPEC))
return 0;
......@@ -136,6 +136,7 @@ int print_linkinfo(const struct sockaddr_nl *who,
if (tb[IFLA_LINK]) {
SPRINT_BUF(b1);
int iflink = rta_getattr_u32(tb[IFLA_LINK]);
if (iflink == 0)
fprintf(fp, "@NONE: ");
else
......@@ -220,7 +221,7 @@ static void usage(void)
{
fprintf(stderr, "Usage: bridge link set dev DEV [ cost COST ] [ priority PRIO ] [ state STATE ]\n");
fprintf(stderr, " [ guard {on | off} ]\n");
fprintf(stderr, " [ hairpin {on | off} ] \n");
fprintf(stderr, " [ hairpin {on | off} ]\n");
fprintf(stderr, " [ fastleave {on | off} ]\n");
fprintf(stderr, " [ root_block {on | off} ]\n");
fprintf(stderr, " [ learning {on | off} ]\n");
......@@ -319,6 +320,7 @@ static int brlink_modify(int argc, char **argv)
NEXT_ARG();
char *endptr;
size_t nstates = sizeof(port_states) / sizeof(*port_states);
state = strtol(*argv, &endptr, 10);
if (!(**argv != '\0' && *endptr == '\0')) {
for (state = 0; state < nstates; state++)
......@@ -339,8 +341,7 @@ static int brlink_modify(int argc, char **argv)
mode = BRIDGE_MODE_VEB;
else {
fprintf(stderr,
"Mode argument must be \"vepa\" or "
"\"veb\".\n");
"Mode argument must be \"vepa\" or \"veb\".\n");
return -1;
}
} else if (strcmp(*argv, "self") == 0) {
......
......@@ -21,7 +21,7 @@
#ifndef MDBA_RTA
#define MDBA_RTA(r) \
((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct br_port_msg))))
((struct rtattr *)(((char *)(r)) + NLMSG_ALIGN(sizeof(struct br_port_msg))))
#endif
static unsigned int filter_index;
......@@ -224,9 +224,9 @@ static int mdb_show(int argc, char **argv)
static int mdb_modify(int cmd, int flags, int argc, char **argv)
{
struct {
struct nlmsghdr n;
struct nlmsghdr n;
struct br_port_msg bpm;
char buf[1024];
char buf[1024];
} req;
struct br_mdb_entry entry;
char *d = NULL, *p = NULL, *grp = NULL;
......
......@@ -76,10 +76,10 @@ static int accept_msg(const struct sockaddr_nl *who,
int do_monitor(int argc, char **argv)
{
char *file = NULL;
unsigned groups = ~RTMGRP_TC;
int llink=0;
int lneigh=0;
int lmdb=0;
unsigned int groups = ~RTMGRP_TC;
int llink = 0;
int lneigh = 0;
int lmdb = 0;
rtnl_close(&rth);
......@@ -88,7 +88,7 @@ int do_monitor(int argc, char **argv)
NEXT_ARG();
file = *argv;
} else if (matches(*argv, "link") == 0) {
llink=1;
llink = 1;
groups = 0;
} else if (matches(*argv, "fdb") == 0) {
lneigh = 1;
......@@ -98,7 +98,7 @@ int do_monitor(int argc, char **argv)
groups = 0;
} else if (strcmp(*argv, "all") == 0) {
groups = ~RTMGRP_TC;
prefix_banner=1;
prefix_banner = 1;
} else if (matches(*argv, "help") == 0) {
usage();
} else {
......@@ -122,6 +122,7 @@ int do_monitor(int argc, char **argv)
if (file) {
FILE *fp;
int err;
fp = fopen(file, "r");
if (fp == NULL) {
perror("Cannot fopen");
......
......@@ -26,9 +26,9 @@ static void usage(void)
static int vlan_modify(int cmd, int argc, char **argv)
{
struct {
struct nlmsghdr n;
struct ifinfomsg ifm;
char buf[1024];
struct nlmsghdr n;
struct ifinfomsg ifm;
char buf[1024];
} req;
char *d = NULL;
short vid = -1;
......@@ -51,6 +51,7 @@ static int vlan_modify(int cmd, int argc, char **argv)
d = *argv;
} else if (strcmp(*argv, "vid") == 0) {
char *p;
NEXT_ARG();
p = strchr(*argv, '-');
if (p) {
......@@ -144,7 +145,7 @@ static int print_vlan(const struct sockaddr_nl *who,
FILE *fp = arg;
struct ifinfomsg *ifm = NLMSG_DATA(n);
int len = n->nlmsg_len;
struct rtattr * tb[IFLA_MAX+1];
struct rtattr *tb[IFLA_MAX+1];
if (n->nlmsg_type != RTM_NEWLINK) {
fprintf(stderr, "Not RTM_NEWLINK: %08x %08x %08x\n",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment