From: Michal Sojka Date: Sun, 16 Oct 2011 20:43:58 +0000 (+0200) Subject: Cosmetic and whitespace fixes X-Git-Url: https://rtime.felk.cvut.cz/gitweb/lisovros/linux_canprio.git/commitdiff_plain/c62d98d68b12528b7a94645c5c787a4d84454ee8 Cosmetic and whitespace fixes --- diff --git a/net/sched/cls_can.c b/net/sched/cls_can.c index 0b956c53288..a423c2b7e8f 100644 --- a/net/sched/cls_can.c +++ b/net/sched/cls_can.c @@ -92,9 +92,9 @@ struct canfltr_state { * ---------------------------------------------------------------------------- */ -#ifdef SFF_BITMAP static void canfltr_sff_match_add(struct canfltr_rules *rls, u32 can_id, u32 can_mask) { +#ifdef SFF_BITMAP int i; /* Limit can_mask and can_id to SFF range to protect against write after end of array */ @@ -119,11 +119,11 @@ static void canfltr_sff_match_add(struct canfltr_rules *rls, u32 can_id, u32 can if ((i & can_mask) == can_id) set_bit(i, rls->match_sff); } -} #endif +} /* - * Extracts Can ID ot ouf the sk_buff structure. + * Extracts Can ID out of the sk_buff structure. */ static canid_t canfltr_get_id(struct sk_buff *skb) { @@ -134,8 +134,8 @@ static canid_t canfltr_get_id(struct sk_buff *skb) } /* - * Performs the classification. Iterates over all instances of filter - * checking for Can ID match. + * Performs the classification. Iterates over all instances of filter, + * checking for CAN ID match. * * @skb: Socket buffer * @tp: @@ -143,7 +143,7 @@ static canid_t canfltr_get_id(struct sk_buff *skb) * * Returns value relevant for policing. Used return values: * TC_POLICE_OK if succesfully classified (without regard to policing rules) - * TC_POLICE_UNSPEC if no matching filter was found + * TC_POLICE_UNSPEC if no matching rule was found */ static int canfltr_classify(struct sk_buff *skb, struct tcf_proto *tp, struct tcf_result *res) @@ -151,10 +151,10 @@ static int canfltr_classify(struct sk_buff *skb, struct tcf_proto *tp, struct canfltr_head *head = (struct canfltr_head *)tp->root; struct canfltr_state *f; struct canfltr_rules *r; - u32 can_id; + canid_t can_id; int i; - can_id = (u32)canfltr_get_id(skb); + can_id = canfltr_get_id(skb); rcu_read_lock(); list_for_each_entry(f, &head->flist, link) { @@ -166,9 +166,8 @@ static int canfltr_classify(struct sk_buff *skb, struct tcf_proto *tp, can_id &= CAN_EFF_MASK; for (i = 0; i < r->eff_rules_count; i++) { - if ((r->rules_raw[i].can_id & r->rules_raw[i].can_mask & CAN_EFF_MASK) == - (can_id & r->rules_raw[i].can_mask & CAN_EFF_MASK)) { - + if ((r->rules_raw[i].can_id & r->rules_raw[i].can_mask & CAN_EFF_MASK) == /* XXX: Why aren't these & performed "off-line"? */ + (can_id & r->rules_raw[i].can_mask & CAN_EFF_MASK)) { match = true; break; } @@ -179,9 +178,8 @@ static int canfltr_classify(struct sk_buff *skb, struct tcf_proto *tp, match = test_bit(can_id, r->match_sff); #else for (i = r->eff_rules_count; i < r->eff_rules_count + r->sff_rules_count; i++) { - if ((r->rules_raw[i].can_id & r->rules_raw[i].can_mask & CAN_SFF_MASK) == - (can_id & r->rules_raw[i].can_mask & CAN_SFF_MASK)) { - + if ((r->rules_raw[i].can_id & r->rules_raw[i].can_mask & CAN_SFF_MASK) == /* XXX: dtto */ + (can_id & r->rules_raw[i].can_mask & CAN_SFF_MASK)) { match = true; break; } @@ -229,7 +227,6 @@ static void canfltr_put(struct tcf_proto *tp, unsigned long f) { } - static unsigned int canfltr_gen_handle(struct tcf_proto *tp) { struct canfltr_head *head = (struct canfltr_head *)tp->root; @@ -248,7 +245,6 @@ static unsigned int canfltr_gen_handle(struct tcf_proto *tp) return 0; } - static void canfltr_rules_free_rcu(struct rcu_head *rcu) { kfree(container_of(rcu, struct canfltr_rules, rcu)); @@ -265,7 +261,7 @@ static int canfltr_set_parms(struct tcf_proto *tp, struct canfltr_state *f, rules_tmp = kzalloc(sizeof(*rules_tmp), GFP_KERNEL); if (rules_tmp == NULL) - return -ENOBUFS; + return -ENOBUFS; /* XXX: Why not -ENOMEM? */ err = -EINVAL; if (tb[TCA_CANFLTR_CLASSID] == NULL) @@ -284,35 +280,31 @@ static int canfltr_set_parms(struct tcf_proto *tp, struct canfltr_state *f, if (rules_tmp->rules_raw == NULL) goto errout; - /* Process EFF frames */ + /* We need two for() loops for copying rules into two contiguous areas in rules_raw */ + + /* Process EFF frame rules*/ for (i = 0; i < rules_tmp->rules_count; i++) { if ((canfltr_nl_rules[i].can_id & CAN_EFF_FLAG) && - (canfltr_nl_rules[i].can_mask & CAN_EFF_FLAG)) { - + (canfltr_nl_rules[i].can_mask & CAN_EFF_FLAG)) { memcpy(rules_tmp->rules_raw + rules_tmp->eff_rules_count, - &canfltr_nl_rules[i], sizeof(struct can_filter)); + &canfltr_nl_rules[i], sizeof(struct can_filter)); rules_tmp->eff_rules_count ++; } else { continue; } } - /* Process SFF frames - We need two for() loops for copying rules into two contiguous areas in rules_raw */ + /* Process SFF frame rules */ for (i = 0; i < rules_tmp->rules_count; i++) { if ((canfltr_nl_rules[i].can_id & CAN_EFF_FLAG) && - (canfltr_nl_rules[i].can_mask & CAN_EFF_FLAG)) { - + (canfltr_nl_rules[i].can_mask & CAN_EFF_FLAG)) { continue; } else { memcpy(rules_tmp->rules_raw + rules_tmp->eff_rules_count + rules_tmp->sff_rules_count, - &canfltr_nl_rules[i], sizeof(struct can_filter)); + &canfltr_nl_rules[i], sizeof(struct can_filter)); rules_tmp->sff_rules_count ++; - -#ifdef SFF_BITMAP canfltr_sff_match_add(rules_tmp, canfltr_nl_rules[i].can_id, canfltr_nl_rules[i].can_mask); -#endif } } } @@ -576,4 +568,3 @@ module_exit(exit_canfltr); MODULE_LICENSE("GPL"); MODULE_AUTHOR(""); // FIXME MODULE_DESCRIPTION("Controller Area Network classifier"); -