[ovs-dev] [cleanups 10/13] classifier: Delete dead code specialized for the exact table.

Ethan Jackson ethan at nicira.com
Sat Nov 13 00:11:50 UTC 2010


Looks Good

On Fri, Oct 29, 2010 at 4:37 PM, Ben Pfaff <blp at nicira.com> wrote:
> These functions and macros are no longer used.
> ---
>  lib/classifier.c        |   50 -----------------------------------------------
>  lib/classifier.h        |   20 ------------------
>  tests/test-classifier.c |   14 -------------
>  3 files changed, 0 insertions(+), 84 deletions(-)
>
> diff --git a/lib/classifier.c b/lib/classifier.c
> index c3c800d..94b5143 100644
> --- a/lib/classifier.c
> +++ b/lib/classifier.c
> @@ -60,48 +60,6 @@ cls_table_from_hmap_node(const struct hmap_node *node)
>     return node ? CONTAINER_OF(node, struct cls_table, hmap_node) : NULL;
>  }
>
> -static struct cls_rule *
> -cls_rule_from_hmap_node(const struct hmap_node *node)
> -{
> -    return node ? CONTAINER_OF(node, struct cls_rule, hmap_node) : NULL;
> -}
> -
> -/* Returns the cls_table within 'cls' that has no wildcards, or NULL if there
> - * is none.  */
> -struct cls_table *
> -classifier_exact_table(const struct classifier *cls)
> -{
> -    struct flow_wildcards exact_wc;
> -    flow_wildcards_init_exact(&exact_wc);
> -    return find_table(cls, &exact_wc);
> -}
> -
> -/* Returns the first rule in 'table', or a null pointer if 'table' is NULL.
> - *
> - * (The classifier never creates empty tables and destroys tables as soon as
> - * they become empty, so if 'table' is null then the return value should always
> - * be nonnull.  However, the implementation of this function is robust
> - * anyhow.) */
> -struct cls_rule *
> -cls_table_first_rule(const struct cls_table *table)
> -{
> -    return table ? cls_rule_from_hmap_node(hmap_first(&table->rules)) : NULL;
> -}
> -
> -/* Returns the next rule in 'table' following 'rule', or a null pointer if
> - * 'rule' is the last rule in 'table'. */
> -struct cls_rule *
> -cls_table_next_rule(const struct cls_table *table, const struct cls_rule *rule)
> -{
> -    struct cls_rule *next
> -        = CONTAINER_OF(rule->list.next, struct cls_rule, hmap_node);
> -
> -    return (next->priority < rule->priority
> -            ? next
> -            : cls_rule_from_hmap_node(hmap_next(&table->rules,
> -                                                &next->hmap_node)));
> -}
> -
>  /* Converts the flow in 'flow' into a cls_rule in 'rule', with the given
>  * 'wildcards' and 'priority'. */
>  void
> @@ -399,14 +357,6 @@ classifier_count(const struct classifier *cls)
>     return cls->n_rules;
>  }
>
> -/* Returns the number of rules in 'classifier' that have no wildcards. */
> -int
> -classifier_count_exact(const struct classifier *cls)
> -{
> -    struct cls_table *exact_table = classifier_exact_table(cls);
> -    return exact_table ? exact_table->n_table_rules : 0;
> -}
> -
>  /* Inserts 'rule' into 'cls'.  Until 'rule' is removed from 'cls', the caller
>  * must not modify or free it.
>  *
> diff --git a/lib/classifier.h b/lib/classifier.h
> index bec29c1..6adef86 100644
> --- a/lib/classifier.h
> +++ b/lib/classifier.h
> @@ -103,9 +103,7 @@ void classifier_init(struct classifier *);
>  void classifier_destroy(struct classifier *);
>  bool classifier_is_empty(const struct classifier *);
>  int classifier_count(const struct classifier *);
> -int classifier_count_exact(const struct classifier *);
>  struct cls_rule *classifier_insert(struct classifier *, struct cls_rule *);
> -void classifier_insert_exact(struct classifier *, struct cls_rule *);
>  void classifier_remove(struct classifier *, struct cls_rule *);
>  struct cls_rule *classifier_lookup(const struct classifier *,
>                                    const struct flow *);
> @@ -122,22 +120,4 @@ void classifier_for_each_match(const struct classifier *,
>  struct cls_rule *classifier_find_rule_exactly(const struct classifier *,
>                                               const struct cls_rule *);
>
> -/* Iteration shorthands. */
> -
> -struct cls_table *classifier_exact_table(const struct classifier *);
> -struct cls_rule *cls_table_first_rule(const struct cls_table *);
> -struct cls_rule *cls_table_next_rule(const struct cls_table *,
> -                                     const struct cls_rule *);
> -
> -#define CLS_TABLE_FOR_EACH_RULE(RULE, MEMBER, TABLE)                    \
> -    for ((RULE) = OBJECT_CONTAINING(cls_table_first_rule(TABLE),        \
> -                                    RULE, MEMBER);                      \
> -         &(RULE)->MEMBER != NULL;                                       \
> -         (RULE) = OBJECT_CONTAINING(cls_table_next_rule(TABLE,          \
> -                                                        &(RULE)->MEMBER), \
> -                                    RULE, MEMBER))
> -
> -#define CLASSIFIER_FOR_EACH_EXACT_RULE(RULE, MEMBER, CLS)               \
> -    CLS_TABLE_FOR_EACH_RULE (RULE, MEMBER, classifier_exact_table(CLS))
> -
>  #endif /* classifier.h */
> diff --git a/tests/test-classifier.c b/tests/test-classifier.c
> index b6a8f66..f57358e 100644
> --- a/tests/test-classifier.c
> +++ b/tests/test-classifier.c
> @@ -125,19 +125,6 @@ tcls_destroy(struct tcls *tcls)
>     }
>  }
>
> -static int
> -tcls_count_exact(const struct tcls *tcls)
> -{
> -    int n_exact;
> -    size_t i;
> -
> -    n_exact = 0;
> -    for (i = 0; i < tcls->n_rules; i++) {
> -        n_exact += tcls->rules[i]->cls_rule.wc.wildcards == 0;
> -    }
> -    return n_exact;
> -}
> -
>  static bool
>  tcls_is_empty(const struct tcls *tcls)
>  {
> @@ -366,7 +353,6 @@ compare_classifiers(struct classifier *cls, struct tcls *tcls)
>     unsigned int i;
>
>     assert(classifier_count(cls) == tcls->n_rules);
> -    assert(classifier_count_exact(cls) == tcls_count_exact(tcls));
>     for (i = 0; i < confidence; i++) {
>         struct cls_rule *cr0, *cr1;
>         struct flow flow;
> --
> 1.7.1
>
>
> _______________________________________________
> dev mailing list
> dev at openvswitch.org
> http://openvswitch.org/mailman/listinfo/dev_openvswitch.org
>




More information about the dev mailing list