[ovs-dev] [PATCH] datapath: Avoid nla_parse_nested const warning on < 2.6.22.
Justin Pettit
jpettit at nicira.com
Mon Jan 31 06:37:03 UTC 2011
Looks good on 2.6.18.8 except for the following warnings:
-=-=-=-=-=-=-=-=-=-=-=-
CC [M] /home/jpettit/src/openvswitch/datapath/linux-2.6/datapath.o
/home/jpettit/src/openvswitch/datapath/linux-2.6/datapath.c:726: warning: initialization discards qualifiers from pointer target type
/home/jpettit/src/openvswitch/datapath/linux-2.6/datapath.c:1178: warning: initialization discards qualifiers from pointer target type
/home/jpettit/src/openvswitch/datapath/linux-2.6/datapath.c:1183: warning: initialization discards qualifiers from pointer target type
/home/jpettit/src/openvswitch/datapath/linux-2.6/datapath.c:1188: warning: initialization discards qualifiers from pointer target type
/home/jpettit/src/openvswitch/datapath/linux-2.6/datapath.c:1194: warning: initialization discards qualifiers from pointer target type
/home/jpettit/src/openvswitch/datapath/linux-2.6/datapath.c:1532: warning: initialization discards qualifiers from pointer target type
/home/jpettit/src/openvswitch/datapath/linux-2.6/datapath.c:1537: warning: initialization discards qualifiers from pointer target type
/home/jpettit/src/openvswitch/datapath/linux-2.6/datapath.c:1542: warning: initialization discards qualifiers from pointer target type
/home/jpettit/src/openvswitch/datapath/linux-2.6/datapath.c:1548: warning: initialization discards qualifiers from pointer target type
/home/jpettit/src/openvswitch/datapath/linux-2.6/datapath.c:1928: warning: initialization discards qualifiers from pointer target type
/home/jpettit/src/openvswitch/datapath/linux-2.6/datapath.c:1933: warning: initialization discards qualifiers from pointer target type
/home/jpettit/src/openvswitch/datapath/linux-2.6/datapath.c:1938: warning: initialization discards qualifiers from pointer target type
/home/jpettit/src/openvswitch/datapath/linux-2.6/datapath.c:1944: warning: initialization discards qualifiers from pointer target type
-=-=-=-=-=-=-=-=-=-=-=-
Otherwise, it builds cleanly.
--Justin
On Jan 30, 2011, at 4:35 PM, Jesse Gross wrote:
> We mark our Netlink policies as const for safety but the argument
> to nla_parse_nested didn't become const until 2.6.22, which provokes
> warnings. This casts away the constness on affected kernels to
> avoid the warnings.
>
> Reported-by: Justin Pettit <jpettit at nicira.com>
> Signed-off-by: Jesse Gross <jesse at nicira.com>
> ---
> When checking this I saw that there were some additional warnings on 2.6.18 as
> a result of passing const policies to genetlink which were similarly not const
> at the time. I didn't see an easy way to handle this with a macro in compat
> code and didn't want to add a lot of casts or drop the constness, so I decided
> to leave it as is. It's not a real problem anyways.
> ---
> .../linux-2.6/compat-2.6/include/net/netlink.h | 5 ++++-
> 1 files changed, 4 insertions(+), 1 deletions(-)
>
> diff --git a/datapath/linux-2.6/compat-2.6/include/net/netlink.h b/datapath/linux-2.6/compat-2.6/include/net/netlink.h
> index f4fb843..0f881f1 100644
> --- a/datapath/linux-2.6/compat-2.6/include/net/netlink.h
> +++ b/datapath/linux-2.6/compat-2.6/include/net/netlink.h
> @@ -111,7 +111,10 @@ static inline int nla_type(const struct nlattr *nla)
> }
> #endif
>
> -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29)
> +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22)
> +#define nla_parse_nested(tb, maxtype, nla, policy) \
> + nla_parse_nested(tb, maxtype, (struct nlattr *)(nla), (struct nla_policy *)(policy))
> +#elif LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29)
> #define nla_parse_nested(tb, maxtype, nla, policy) \
> nla_parse_nested(tb, maxtype, (struct nlattr *)(nla), policy)
> #endif
> --
> 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