[ovs-dev] [cleanups 08/13] test-classifier: Use get_unaligned_u32() from unaligned.h.

Ethan Jackson ethan at nicira.com
Fri Nov 12 21:47:28 UTC 2010


Looks fine.

On Fri, Oct 29, 2010 at 4:37 PM, Ben Pfaff <blp at nicira.com> wrote:
> There's no point in defining our own code to do this here.
> ---
>  tests/test-classifier.c |   13 +++----------
>  1 files changed, 3 insertions(+), 10 deletions(-)
>
> diff --git a/tests/test-classifier.c b/tests/test-classifier.c
> index 3623469..45dd338 100644
> --- a/tests/test-classifier.c
> +++ b/tests/test-classifier.c
> @@ -33,6 +33,7 @@
>  #include "command-line.h"
>  #include "flow.h"
>  #include "packets.h"
> +#include "unaligned.h"
>
>  #undef NDEBUG
>  #include <assert.h>
> @@ -195,14 +196,6 @@ tcls_remove(struct tcls *cls, const struct test_rule *rule)
>     NOT_REACHED();
>  }
>
> -static uint32_t
> -read_uint32(const void *p)
> -{
> -    uint32_t x;
> -    memcpy(&x, p, sizeof x);
> -    return x;
> -}
> -
>  static bool
>  match(const struct cls_rule *wild, const struct flow *fixed)
>  {
> @@ -220,8 +213,8 @@ match(const struct cls_rule *wild, const struct flow *fixed)
>         }
>
>         if (wild->wc.wildcards & f->wildcards) {
> -            uint32_t test = read_uint32(wild_field);
> -            uint32_t ip = read_uint32(fixed_field);
> +            uint32_t test = get_unaligned_u32(wild_field);
> +            uint32_t ip = get_unaligned_u32(fixed_field);
>             int shift = (f_idx == CLS_F_IDX_NW_SRC
>                          ? OFPFW_NW_SRC_SHIFT : OFPFW_NW_DST_SHIFT);
>             uint32_t mask = flow_nw_bits_to_mask(wild->wc.wildcards, shift);
> --
> 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