Commit ec7aff5c authored by Stephen Hemminger's avatar Stephen Hemminger

ip: fix all the checkpatch warnings

Zhang Shengju some places where tabs were not being used.
Go ahead and fix all the trival checkpatch warnings in ip/ip.c
Also fix bridge.c
parent 99bb68ff
......@@ -18,12 +18,12 @@
struct rtnl_handle rth = { .fd = -1 };
int preferred_family = AF_UNSPEC;
int resolve_hosts;
int oneline = 0;
int oneline;
int show_stats;
int show_details;
int compress_vlans;
int timestamp;
char * _SL_ = NULL;
const char *_SL_;
static void usage(void) __attribute__((noreturn));
......@@ -31,10 +31,10 @@ static void usage(void)
{
fprintf(stderr,
"Usage: bridge [ OPTIONS ] OBJECT { COMMAND | help }\n"
"where OBJECT := { link | fdb | mdb | vlan | monitor }\n"
" OPTIONS := { -V[ersion] | -s[tatistics] | -d[etails] |\n"
" -o[neline] | -t[imestamp] | -n[etns] name |\n"
" -c[ompressvlans] }\n");
"where OBJECT := { link | fdb | mdb | vlan | monitor }\n"
" OPTIONS := { -V[ersion] | -s[tatistics] | -d[etails] |\n"
" -o[neline] | -t[imestamp] | -n[etns] name |\n"
" -c[ompressvlans] }\n");
exit(-1);
}
......@@ -48,9 +48,9 @@ static const struct cmd {
const char *cmd;
int (*func)(int argc, char **argv);
} cmds[] = {
{ "link", do_link },
{ "fdb", do_fdb },
{ "mdb", do_mdb },
{ "link", do_link },
{ "fdb", do_fdb },
{ "mdb", do_mdb },
{ "vlan", do_vlan },
{ "monitor", do_monitor },
{ "help", do_help },
......@@ -66,7 +66,8 @@ static int do_cmd(const char *argv0, int argc, char **argv)
return c->func(argc-1, argv+1);
}
fprintf(stderr, "Object \"%s\" is unknown, try \"bridge help\".\n", argv0);
fprintf(stderr,
"Object \"%s\" is unknown, try \"bridge help\".\n", argv0);
return -1;
}
......@@ -74,8 +75,9 @@ int
main(int argc, char **argv)
{
while (argc > 1) {
char *opt = argv[1];
if (strcmp(opt,"--") == 0) {
const char *opt = argv[1];
if (strcmp(opt, "--") == 0) {
argc--; argv++;
break;
}
......@@ -98,7 +100,7 @@ main(int argc, char **argv)
++oneline;
} else if (matches(opt, "-timestamp") == 0) {
++timestamp;
} else if (matches(opt, "-family") == 0) {
} else if (matches(opt, "-family") == 0) {
argc--;
argv++;
if (argc <= 1)
......@@ -122,13 +124,15 @@ main(int argc, char **argv)
} else if (matches(opt, "-compressvlans") == 0) {
++compress_vlans;
} else {
fprintf(stderr, "Option \"%s\" is unknown, try \"bridge help\".\n", opt);
fprintf(stderr,
"Option \"%s\" is unknown, try \"bridge help\".\n",
opt);
exit(-1);
}
argc--; argv++;
}
_SL_ = oneline ? "\\" : "\n" ;
_SL_ = oneline ? "\\" : "\n";
if (rtnl_open(&rth, 0) < 0)
exit(1);
......
......@@ -21,7 +21,7 @@ extern int resolve_hosts;
extern int oneline;
extern int timestamp;
extern int timestamp_short;
extern char * _SL_;
extern const char * _SL_;
extern int max_flush_loops;
extern int batch_mode;
extern bool do_all;
......
......@@ -26,18 +26,18 @@
#include "color.h"
int preferred_family = AF_UNSPEC;
int human_readable = 0;
int use_iec = 0;
int show_stats = 0;
int show_details = 0;
int resolve_hosts = 0;
int oneline = 0;
int timestamp = 0;
char * _SL_ = NULL;
int force = 0;
int human_readable;
int use_iec;
int show_stats;
int show_details;
int resolve_hosts;
int oneline;
int timestamp;
const char *_SL_;
int force;
int max_flush_loops = 10;
int batch_mode = 0;
bool do_all = false;
int batch_mode;
bool do_all;
struct rtnl_handle rth = { .fd = -1 };
......@@ -64,7 +64,7 @@ static void usage(void)
static int do_help(int argc, char **argv)
{
usage();
return 0;
return 0;
}
static const struct cmd {
......@@ -89,7 +89,7 @@ static const struct cmd {
{ "tap", do_iptuntap },
{ "token", do_iptoken },
{ "tcpmetrics", do_tcp_metrics },
{ "tcp_metrics",do_tcp_metrics },
{ "tcp_metrics", do_tcp_metrics },
{ "monitor", do_ipmonitor },
{ "xfrm", do_xfrm },
{ "mroute", do_multiroute },
......@@ -105,9 +105,8 @@ static int do_cmd(const char *argv0, int argc, char **argv)
const struct cmd *c;
for (c = cmds; c->cmd; ++c) {
if (matches(argv0, c->cmd) == 0) {
if (matches(argv0, c->cmd) == 0)
return -(c->func(argc-1, argv+1));
}
}
fprintf(stderr, "Object \"%s\" is unknown, try \"ip help\".\n", argv0);
......@@ -124,7 +123,8 @@ static int batch(const char *name)
if (name && strcmp(name, "-") != 0) {
if (freopen(name, "r", stdin) == NULL) {
fprintf(stderr, "Cannot open file \"%s\" for reading: %s\n",
fprintf(stderr,
"Cannot open file \"%s\" for reading: %s\n",
name, strerror(errno));
return EXIT_FAILURE;
}
......@@ -145,7 +145,8 @@ static int batch(const char *name)
continue; /* blank line */
if (do_cmd(largv[0], largc, largv)) {
fprintf(stderr, "Command failed %s:%d\n", name, cmdlineno);
fprintf(stderr, "Command failed %s:%d\n",
name, cmdlineno);
ret = EXIT_FAILURE;
if (!force)
break;
......@@ -172,7 +173,8 @@ int main(int argc, char **argv)
while (argc > 1) {
char *opt = argv[1];
if (strcmp(opt,"--") == 0) {
if (strcmp(opt, "--") == 0) {
argc--; argv++;
break;
}
......@@ -185,8 +187,8 @@ int main(int argc, char **argv)
argv++;
if (argc <= 1)
usage();
max_flush_loops = atoi(argv[1]);
} else if (matches(opt, "-family") == 0) {
max_flush_loops = atoi(argv[1]);
} else if (matches(opt, "-family") == 0) {
argc--;
argv++;
if (argc <= 1)
......@@ -269,13 +271,15 @@ int main(int argc, char **argv)
} else if (matches(opt, "-all") == 0) {
do_all = true;
} else {
fprintf(stderr, "Option \"%s\" is unknown, try \"ip -help\".\n", opt);
fprintf(stderr,
"Option \"%s\" is unknown, try \"ip -help\".\n",
opt);
exit(-1);
}
argc--; argv++;
}
_SL_ = oneline ? "\\" : "\n" ;
_SL_ = oneline ? "\\" : "\n";
if (batch_file)
return batch(batch_file);
......
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