diff options
Diffstat (limited to 'tc/tc.c')
-rw-r--r-- | tc/tc.c | 44 |
1 files changed, 20 insertions, 24 deletions
@@ -31,26 +31,25 @@ #include "tc_common.h" #include "namespace.h" -int show_stats = 0; -int show_details = 0; -int show_raw = 0; -int show_pretty = 0; -int show_graph = 0; +int show_stats; +int show_details; +int show_raw; +int show_pretty; +int show_graph; int timestamp; -int batch_mode = 0; -int resolve_hosts = 0; -int use_iec = 0; -int force = 0; -bool use_names = false; +int batch_mode; +int use_iec; +int force; +bool use_names; static char *conf_file; struct rtnl_handle rth; -static void *BODY = NULL; /* cached handle dlopen(NULL) */ -static struct qdisc_util * qdisc_list; -static struct filter_util * filter_list; +static void *BODY; /* cached handle dlopen(NULL) */ +static struct qdisc_util *qdisc_list; +static struct filter_util *filter_list; #ifdef ANDROID extern struct qdisc_util cbq_qdisc_util; @@ -64,7 +63,7 @@ static int print_noqopt(struct qdisc_util *qu, FILE *f, { if (opt && RTA_PAYLOAD(opt)) fprintf(f, "[Unknown qdisc, optlen=%u] ", - (unsigned) RTA_PAYLOAD(opt)); + (unsigned int) RTA_PAYLOAD(opt)); return 0; } @@ -81,7 +80,7 @@ static int print_nofopt(struct filter_util *qu, FILE *f, struct rtattr *opt, __u { if (opt && RTA_PAYLOAD(opt)) fprintf(f, "fh %08x [Unknown filter, optlen=%u] ", - fhandle, (unsigned) RTA_PAYLOAD(opt)); + fhandle, (unsigned int) RTA_PAYLOAD(opt)); else if (fhandle) fprintf(f, "fh %08x ", fhandle); return 0; @@ -97,6 +96,7 @@ static int parse_nofopt(struct filter_util *qu, char *fhandle, int argc, char ** } if (fhandle) { struct tcmsg *t = NLMSG_DATA(n); + if (get_u32(&handle, fhandle, 16)) { fprintf(stderr, "Unparsable filter ID \"%s\"\n", fhandle); return -1; @@ -151,11 +151,9 @@ reg: return q; noexist: - q = malloc(sizeof(*q)); + q = calloc(1, sizeof(*q)); if (q) { - - memset(q, 0, sizeof(*q)); - q->id = strcpy(malloc(strlen(str)+1), str); + q->id = strdup(str); q->parse_qopt = parse_noqopt; q->print_qopt = print_noqopt; goto reg; @@ -203,9 +201,8 @@ reg: filter_list = q; return q; noexist: - q = malloc(sizeof(*q)); + q = calloc(1, sizeof(*q)); if (q) { - memset(q, 0, sizeof(*q)); strncpy(q->id, str, 15); q->parse_fopt = parse_nofopt; q->print_fopt = print_nofopt; @@ -222,9 +219,8 @@ static void usage(void) #else " tc [-force] -batch filename\n" #endif - "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" + "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 }\n"); } |