Hi,
in porting the ovs kernel code to the FreeBSD kernel,
compiling with -Wcast-qual -Werror gives some
warning: cast discards qualifiers from pointer target type
due to 'const' being ignored. Another couple of warnings
are on arguments to format strings.
Attached is a trivial patch (partly from Daniele Di Proietto) that
addresses some of the cases; however, some of them could be
fixed in different ways.
In particular, vport_priv() and vport_from_priv() should be
changed to return a const pointer, but this has a bit of
an avalanche effect on the code and I am not sure if you are
willing to go for it.
We are happy to submit a proper patch according to your
preferences.
In case you just want to use this, here is the signoff
Signed-off-by: Luigi Rizzo <[email protected]>
Signed-off-by: Daniele Di Proietto <[email protected]>
cheers
luigi
--
-----------------------------------------+-------------------------------
Prof. Luigi RIZZO, [email protected] . Dip. di Ing. dell'Informazione
http://www.iet.unipi.it/~luigi/ . Universita` di Pisa
TEL +39-050-2211611 . via Diotisalvi 2
Mobile +39-338-6809875 . 56122 PISA (Italy)
-----------------------------------------+-------------------------------
diff --git a/openvswitch/flow.c b/openvswitch/flow.c
index 410db90..52f6c36 100644
--- a/openvswitch/flow.c
+++ b/openvswitch/flow.c
@@ -229,14 +229,14 @@ static bool ovs_match_validate(const struct sw_flow_match
*match,
if ((key_attrs & key_expected) != key_expected) {
/* Key attributes check failed. */
OVS_NLERR("Missing expected key attributes (key_attrs=%llx,
expected=%llx).\n",
- key_attrs, key_expected);
+ (unsigned long long)key_attrs, (unsigned long
long)key_expected);
return false;
}
if ((mask_attrs & mask_allowed) != mask_attrs) {
/* Mask attributes check failed. */
OVS_NLERR("Contain more than allowed mask fields
(mask_attrs=%llx, mask_allowed=%llx).\n",
- mask_attrs, mask_allowed);
+ (unsigned long long)mask_attrs, (unsigned long
long)mask_allowed);
return false;
}
@@ -375,8 +375,8 @@ static bool icmp6hdr_ok(struct sk_buff *skb)
void ovs_flow_key_mask(struct sw_flow_key *dst, const struct sw_flow_key *src,
const struct sw_flow_mask *mask)
{
- const long *m = (long *)((u8 *)&mask->key + mask->range.start);
- const long *s = (long *)((u8 *)src + mask->range.start);
+ const long *m = (const long *)((const u8 *)&mask->key +
mask->range.start);
+ const long *s = (const long *)((const u8 *)src + mask->range.start);
long *d = (long *)((u8 *)dst + mask->range.start);
int i;
@@ -1006,7 +1012,7 @@ int ovs_flow_extract(struct sk_buff *skb, u16 in_port,
struct sw_flow_key *key)
static u32 ovs_flow_hash(const struct sw_flow_key *key, int key_start,
int key_end)
{
- u32 *hash_key = (u32 *)((u8 *)key + key_start);
+ const u32 *hash_key = (const u32 *)((const u8 *)key + key_start);
int hash_u32s = (key_end - key_start) >> 2;
/* Make sure number of hash bytes are multiple of u32. */
@@ -1027,8 +1033,8 @@ static int flow_key_start(const struct sw_flow_key *key)
static bool __cmp_key(const struct sw_flow_key *key1,
const struct sw_flow_key *key2, int key_start, int key_end)
{
- const long *cp1 = (long *)((u8 *)key1 + key_start);
- const long *cp2 = (long *)((u8 *)key2 + key_start);
+ const long *cp1 = (const long *)((const u8 *)key1 + key_start);
+ const long *cp2 = (const long *)((const u8 *)key2 + key_start);
long diffs = 0;
int i;
@@ -2035,8 +2041,8 @@ void ovs_sw_flow_mask_del_ref(struct sw_flow_mask *mask,
bool deferred)
static bool ovs_sw_flow_mask_equal(const struct sw_flow_mask *a,
const struct sw_flow_mask *b)
{
- u8 *a_ = (u8 *)&a->key + a->range.start;
- u8 *b_ = (u8 *)&b->key + b->range.start;
+ const u8 *a_ = (const u8 *)&a->key + a->range.start;
+ const u8 *b_ = (const u8 *)&b->key + b->range.start;
return (a->range.end == b->range.end)
&& (a->range.start == b->range.start)
diff --git a/openvswitch/vport.h b/openvswitch/vport.h
index 1a9fbce..36f74e1 100644
--- a/openvswitch/vport.h
+++ b/openvswitch/vport.h
@@ -172,7 +172,7 @@ void ovs_vport_deferred_free(struct vport *vport);
*/
static inline void *vport_priv(const struct vport *vport)
{
- return (u8 *)vport + ALIGN(sizeof(struct vport), VPORT_ALIGN);
+ return (u8 *)(uintptr_t)vport + ALIGN(sizeof(struct vport),
VPORT_ALIGN);
}
/**
@@ -187,7 +187,7 @@ static inline void *vport_priv(const struct vport *vport)
*/
static inline struct vport *vport_from_priv(const void *priv)
{
- return (struct vport *)(priv - ALIGN(sizeof(struct vport),
VPORT_ALIGN));
+ return (struct vport *)((u8*)(uintptr_t)priv - ALIGN(sizeof(struct
vport), VPORT_ALIGN));
}
void ovs_vport_receive(struct vport *, struct sk_buff *,
_______________________________________________
dev mailing list
[email protected]
http://openvswitch.org/mailman/listinfo/dev