]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
tc: cleanup style of qdisc code
authorStephen Hemminger <stephen@networkplumber.org>
Tue, 15 Nov 2016 18:29:09 +0000 (10:29 -0800)
committerStephen Hemminger <sthemmin@microsoft.com>
Tue, 29 Nov 2016 19:41:58 +0000 (11:41 -0800)
Get rid of lingering mismatches with kernel style.

tc/tc_qdisc.c

index 51320bd47766f4d2ccd58e74d63bef6706f6a900..3a3701c20470436a6481f58d0fcc3d6843a78655 100644 (file)
@@ -182,7 +182,8 @@ static int tc_qdisc_modify(int cmd, unsigned int flags, int argc, char **argv)
 
                ll_init_map(&rth);
 
-               if ((idx = ll_name_to_index(d)) == 0) {
+               idx = ll_name_to_index(d);
+               if (idx == 0) {
                        fprintf(stderr, "Cannot find device \"%s\"\n", d);
                        return 1;
                }
@@ -198,8 +199,7 @@ static int tc_qdisc_modify(int cmd, unsigned int flags, int argc, char **argv)
 static int filter_ifindex;
 
 int print_qdisc(const struct sockaddr_nl *who,
-                      struct nlmsghdr *n,
-                      void *arg)
+               struct nlmsghdr *n, void *arg)
 {
        FILE *fp = (FILE *)arg;
        struct tcmsg *t = NLMSG_DATA(n);
@@ -241,18 +241,19 @@ int print_qdisc(const struct sockaddr_nl *who,
 
        if (filter_ifindex == 0)
                fprintf(fp, "dev %s ", ll_index_to_name(t->tcm_ifindex));
+
        if (t->tcm_parent == TC_H_ROOT)
                fprintf(fp, "root ");
        else if (t->tcm_parent) {
                print_tc_classid(abuf, sizeof(abuf), t->tcm_parent);
                fprintf(fp, "parent %s ", abuf);
        }
-       if (t->tcm_info != 1) {
+
+       if (t->tcm_info != 1)
                fprintf(fp, "refcnt %d ", t->tcm_info);
-       }
-       /* pfifo_fast is generic enough to warrant the hardcoding --JHS */
 
-       if (0 == strcmp("pfifo_fast", RTA_DATA(tb[TCA_KIND])))
+       /* pfifo_fast is generic enough to warrant the hardcoding --JHS */
+       if (strcmp("pfifo_fast", RTA_DATA(tb[TCA_KIND])) == 0)
                q = get_qdisc_kind("prio");
        else
                q = get_qdisc_kind(RTA_DATA(tb[TCA_KIND]));
@@ -264,10 +265,12 @@ int print_qdisc(const struct sockaddr_nl *who,
                        fprintf(fp, "[cannot parse qdisc parameters]");
        }
        fprintf(fp, "\n");
+
        if (show_details && tb[TCA_STAB]) {
                print_size_table(fp, " ", tb[TCA_STAB]);
                fprintf(fp, "\n");
        }
+
        if (show_stats) {
                struct rtattr *xstats = NULL;
 
@@ -296,11 +299,11 @@ static int tc_qdisc_list(int argc, char **argv)
                        strncpy(d, *argv, sizeof(d)-1);
                } else if (strcmp(*argv, "ingress") == 0 ||
                           strcmp(*argv, "clsact") == 0) {
-                            if (t.tcm_parent) {
-                                    fprintf(stderr, "Duplicate parent ID\n");
-                                    usage();
-                            }
-                            t.tcm_parent = TC_H_INGRESS;
+                       if (t.tcm_parent) {
+                               fprintf(stderr, "Duplicate parent ID\n");
+                               usage();
+                       }
+                       t.tcm_parent = TC_H_INGRESS;
                } else if (matches(*argv, "help") == 0) {
                        usage();
                } else {
@@ -314,7 +317,8 @@ static int tc_qdisc_list(int argc, char **argv)
        ll_init_map(&rth);
 
        if (d[0]) {
-               if ((t.tcm_ifindex = ll_name_to_index(d)) == 0) {
+               t.tcm_ifindex = ll_name_to_index(d);
+               if (t.tcm_ifindex == 0) {
                        fprintf(stderr, "Cannot find device \"%s\"\n", d);
                        return 1;
                }