tc: help and whitespace cleanup
Break long lines, and cleanup usage message. Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
This commit is contained in:
parent
ba2fc55b99
commit
fec62c0ec7
46
tc/tc.c
46
tc/tc.c
|
|
@ -60,10 +60,13 @@ static int print_noqopt(struct qdisc_util *qu, FILE *f,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int parse_noqopt(struct qdisc_util *qu, int argc, char **argv, struct nlmsghdr *n, const char *dev)
|
||||
static int parse_noqopt(struct qdisc_util *qu, int argc, char **argv,
|
||||
struct nlmsghdr *n, const char *dev)
|
||||
{
|
||||
if (argc) {
|
||||
fprintf(stderr, "Unknown qdisc \"%s\", hence option \"%s\" is unparsable\n", qu->id, *argv);
|
||||
fprintf(stderr,
|
||||
"Unknown qdisc \"%s\", hence option \"%s\" is unparsable\n",
|
||||
qu->id, *argv);
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -79,12 +82,15 @@ static int print_nofopt(struct filter_util *qu, FILE *f, struct rtattr *opt, __u
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int parse_nofopt(struct filter_util *qu, char *fhandle, int argc, char **argv, struct nlmsghdr *n)
|
||||
static int parse_nofopt(struct filter_util *qu, char *fhandle,
|
||||
int argc, char **argv, struct nlmsghdr *n)
|
||||
{
|
||||
__u32 handle;
|
||||
|
||||
if (argc) {
|
||||
fprintf(stderr, "Unknown filter \"%s\", hence option \"%s\" is unparsable\n", qu->id, *argv);
|
||||
fprintf(stderr,
|
||||
"Unknown filter \"%s\", hence option \"%s\" is unparsable\n",
|
||||
qu->id, *argv);
|
||||
return -1;
|
||||
}
|
||||
if (fhandle) {
|
||||
|
|
@ -186,11 +192,14 @@ noexist:
|
|||
|
||||
static void usage(void)
|
||||
{
|
||||
fprintf(stderr, "Usage: tc [ OPTIONS ] OBJECT { COMMAND | help }\n"
|
||||
" tc [-force] -batch filename\n"
|
||||
"where OBJECT := { qdisc | class | filter | action | monitor | exec }\n"
|
||||
" OPTIONS := { -s[tatistics] | -d[etails] | -r[aw] | -p[retty] | -b[atch] [filename] | -n[etns] name |\n"
|
||||
" -nm | -nam[es] | { -cf | -conf } path } | -j[son]\n");
|
||||
fprintf(stderr,
|
||||
"Usage: tc [ OPTIONS ] OBJECT { COMMAND | help }\n"
|
||||
" tc [-force] -batch filename\n"
|
||||
"where OBJECT := { qdisc | class | filter | action | monitor | exec }\n"
|
||||
" OPTIONS := { -V[ersion] | -s[tatistics] | -d[etails] | -r[aw] |\n"
|
||||
" -j[son] | -p[retty] |\n"
|
||||
" -b[atch] [filename] | -n[etns] name |\n"
|
||||
" -nm | -nam[es] | { -cf | -conf } path }\n");
|
||||
}
|
||||
|
||||
static int do_cmd(int argc, char **argv, void *buf, size_t buflen)
|
||||
|
|
@ -224,8 +233,8 @@ static bool batchsize_enabled(int argc, char *argv[])
|
|||
char *c;
|
||||
char *subc[TC_MAX_SUBC];
|
||||
} table[] = {
|
||||
{"filter", {"add", "delete", "change", "replace", NULL}},
|
||||
{"actions", {"add", "change", "replace", NULL}},
|
||||
{ "filter", { "add", "delete", "change", "replace", NULL} },
|
||||
{ "actions", { "add", "change", "replace", NULL} },
|
||||
{ NULL },
|
||||
}, *iter;
|
||||
char *s;
|
||||
|
|
@ -262,11 +271,11 @@ static struct batch_buf *get_batch_buf(struct batch_buf **pool,
|
|||
struct batch_buf *buf;
|
||||
|
||||
if (*pool == NULL)
|
||||
buf = calloc(1, sizeof (struct batch_buf));
|
||||
buf = calloc(1, sizeof(struct batch_buf));
|
||||
else {
|
||||
buf = *pool;
|
||||
*pool = (*pool)->next;
|
||||
memset(buf, 0, sizeof (struct batch_buf));
|
||||
memset(buf, 0, sizeof(struct batch_buf));
|
||||
}
|
||||
|
||||
if (*head == NULL)
|
||||
|
|
@ -325,7 +334,8 @@ static int batch(const char *name)
|
|||
batch_mode = 1;
|
||||
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 -1;
|
||||
}
|
||||
|
|
@ -388,7 +398,7 @@ static int batch(const char *name)
|
|||
}
|
||||
|
||||
ret = do_cmd(largc, largv, tail == NULL ? NULL : tail->buf,
|
||||
tail == NULL ? 0 : sizeof (tail->buf));
|
||||
tail == NULL ? 0 : sizeof(tail->buf));
|
||||
if (ret != 0) {
|
||||
fprintf(stderr, "Command failed %s:%d\n", name,
|
||||
cmdlineno - 1);
|
||||
|
|
@ -404,7 +414,7 @@ static int batch(const char *name)
|
|||
struct batch_buf *buf;
|
||||
struct nlmsghdr *n;
|
||||
|
||||
iov = iovs = malloc(batchsize * sizeof (struct iovec));
|
||||
iov = iovs = malloc(batchsize * sizeof(struct iovec));
|
||||
for (buf = head; buf != NULL; buf = buf->next, ++iov) {
|
||||
n = (struct nlmsghdr *)&buf->buf;
|
||||
iov->iov_base = n;
|
||||
|
|
@ -485,7 +495,9 @@ int main(int argc, char **argv)
|
|||
} else if (matches(argv[1], "-json") == 0) {
|
||||
++json;
|
||||
} else {
|
||||
fprintf(stderr, "Option \"%s\" is unknown, try \"tc -help\".\n", argv[1]);
|
||||
fprintf(stderr,
|
||||
"Option \"%s\" is unknown, try \"tc -help\".\n",
|
||||
argv[1]);
|
||||
return -1;
|
||||
}
|
||||
argc--; argv++;
|
||||
|
|
|
|||
Loading…
Reference in New Issue