Clang complains about the fact that we use a byte array to scan
Geneve attributes into since there are different alignment requirements:

lib/odp-util.c:2936:30: error: cast from 'uint8_t *' (aka 'unsigned char *') to

      'struct geneve_opt *' increases required alignment from 1 to 2

      [-Werror,-Wcast-align]

    struct geneve_opt *opt = (struct geneve_opt *)key->d;

                             ^~~~~~~~~~~~~~~~~~~~~~~~~~~

We can instead treat this as an array of Geneve option headers to
ensure we get the right alignment and then there are no need for
casts.

Reported-by: Joe Stringer <[email protected]>
Signed-off-by: Jesse Gross <[email protected]>
---
 lib/odp-util.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/odp-util.c b/lib/odp-util.c
index c3497ea..3204d16 100644
--- a/lib/odp-util.c
+++ b/lib/odp-util.c
@@ -2925,7 +2925,7 @@ scan_vxlan_gbp(const char *s, uint32_t *key, uint32_t 
*mask)
 }
 
 struct geneve_scan {
-    uint8_t d[252];
+    struct geneve_opt d[63];
     int len;
 };
 
@@ -2933,8 +2933,8 @@ static int
 scan_geneve(const char *s, struct geneve_scan *key, struct geneve_scan *mask)
 {
     const char *s_base = s;
-    struct geneve_opt *opt = (struct geneve_opt *)key->d;
-    struct geneve_opt *opt_mask = (struct geneve_opt *)(mask ? mask->d : NULL);
+    struct geneve_opt *opt = key->d;
+    struct geneve_opt *opt_mask = mask ? mask->d : NULL;
     int len_remain = sizeof key->d;
 
     while (s[0] == '{' && len_remain >= sizeof *opt) {
-- 
2.1.0

_______________________________________________
dev mailing list
[email protected]
http://openvswitch.org/mailman/listinfo/dev

Reply via email to