]> rtime.felk.cvut.cz Git - lisovros/linux_canprio.git/commitdiff
Add notes and coding style fixes
authorMichal Sojka <sojkam1@fel.cvut.cz>
Wed, 17 Aug 2011 11:57:49 +0000 (13:57 +0200)
committerMichal Sojka <sojkam1@fel.cvut.cz>
Wed, 17 Aug 2011 11:57:49 +0000 (13:57 +0200)
net/sched/cls_canprio.c

index 2f19fb94295df244be1ac8ef7ae33470c8138c8c..2d3b4a27e85f0c22f458ec795414a998e40bc0ae 100644 (file)
@@ -45,7 +45,7 @@ enum {
 static const struct nla_policy canprio_policy[TCA_CANPRIO_MAX + 1] = {
        [TCA_CANPRIO_CLASSID]    = { .type = NLA_U32 },
        //FIXME Be aware of possible problems with 64bit kernel and 32bit userspace etc.
-       [TCA_CANPRIO_RULES]      = { .len = sizeof(canprio_rules) }, 
+       [TCA_CANPRIO_RULES]      = { .len = sizeof(canprio_rules) }, /* FIXME */
        [TCA_CANPRIO_INV_EN]     = { .type = NLA_U32 },
 };
 
@@ -153,7 +153,7 @@ static int canprio_classify(struct sk_buff *skb, struct tcf_proto *tp,
        canid = canprio_get_id(skb);
 
        list_for_each_entry(f, &head->flist, link) {
-               int match = 0;
+               bool match = false;
                printk("  canprio_classify() can ID of received frame = 0x%x\n", canid);
 
                if (canid & CAN_EFF_FLAG) {
@@ -163,17 +163,15 @@ static int canprio_classify(struct sk_buff *skb, struct tcf_proto *tp,
                        rcu_read_lock();
 
                        hlist_for_each_entry_rcu(effi, next, &f->match_eff, list) {
-                               if((effi->canid ^ canid) & effi->mask) {
-                                       match = 1;
+                               if ((effi->canid ^ canid) & effi->mask) {
+                                       match = true;
                                        break;
                                }
                        }
 
                        rcu_read_unlock();
                } else {
-                       if(test_bit(canid, f->match_sff)) {
-                               match = 1;
-                       }
+                       match = test_bit(canid, f->match_sff);
                }
 
                if (f->inv_match_en)
@@ -322,6 +320,9 @@ static int canprio_change(struct tcf_proto *tp, unsigned long base, u32 handle,
        printk(" rules_count = %u\n", canprio_rules_count);
 
        for (i = 0; i < canprio_rules_count; i++) {
+               /* FIXME: shouldn't use here the same logic as in
+                * can_rcv_filter() to filter for various combination
+                * of flags (EFF, RTR) */
                if (canprio_rules[i].canid & CAN_EFF_FLAG) {
                        err = eff_match_add(f, canprio_rules[i].canid, canprio_rules[i].canid_mask);
                        if (err < 0)
@@ -419,6 +420,7 @@ static int canprio_init(struct tcf_proto *tp)
                return -ENOBUFS;
        INIT_LIST_HEAD(&head->flist);
        tp->root = head;
+       tp->protocol = htons(ETH_P_CAN); /* Work only on AF_CAN packets - not tested! */
 
        return 0;
 }