loci: cleanup of_memmask and remove of_match_values_mask
diff --git a/c_gen/c_match.py b/c_gen/c_match.py
index 53cd944..b5ef80a 100644
--- a/c_gen/c_match.py
+++ b/c_gen/c_match.py
@@ -177,27 +177,19 @@
of_match_fields_t masks;
} of_match_t;
-/**
- * Mask the values in the match structure according to its fields
+/*
+ * AND 'len' bytes starting from 'value' with the corresponding byte in
+ * 'mask'.
*/
-static inline void of_match_values_mask(of_match_t *match)
-{
- int idx;
-
- for (idx = 0; idx < sizeof(of_match_fields_t); idx++) {
- ((uint8_t *)&match->fields)[idx] &= ((uint8_t *)&match->masks)[idx];
- }
-}
-
static inline void
-of_memmask(void *_fields, void *_masks, size_t len)
+of_memmask(void *value, const void *mask, size_t len)
{
- int idx;
- uint8_t *fields = _fields;
- uint8_t *masks = _masks;
+ int i;
+ uint8_t *v = value;
+ const uint8_t *m = mask;
- for (idx = 0; idx < len; idx++) {
- fields[idx] &= masks[idx];
+ for (i = 0; i < len; i++) {
+ v[i] &= m[i];
}
}
diff --git a/c_gen/c_test_gen.py b/c_gen/c_test_gen.py
index 01f1c5d..6cc9612 100644
--- a/c_gen/c_test_gen.py
+++ b/c_gen/c_test_gen.py
@@ -272,7 +272,7 @@
}
/* Restrict values according to masks */
- of_match_values_mask(match);
+ of_memmask(&match->fields, &match->masks, sizeof(match->fields));
return value;
}