[dpdk-dev] [PATCH] table: fix build error with gcc 8

Van Haaren, Harry harry.van.haaren at intel.com
Tue Apr 10 14:32:43 CEST 2018


+CC Neil from other reply

> From: Dumitrescu, Cristian
> Sent: Monday, April 9, 2018 6:27 PM
> To: Ananyev, Konstantin <konstantin.ananyev at intel.com>; Van Haaren, Harry
> <harry.van.haaren at intel.com>; Stephen Hemminger <stephen at networkplumber.org>;
> Singh, Jasvinder <jasvinder.singh at intel.com>; Richardson, Bruce
> <bruce.richardson at intel.com>
> Cc: dev at dpdk.org
> Subject: RE: [dpdk-dev] [PATCH] table: fix build error with gcc 8
> 
> > >
> > > If people think that this function conversion is not nice, it can be
> reworked
> > in multiple ways at the expense of API (but not ABI) change:
> > > 1. Define the hash function field in the table parameter structure as
> > opaque void * rather than 4-parameter version.
> > > 2. Create a separate parameter structure just for this hash table type.
> >
> > Why just not define your f_hash member as a union:
> >
> > struct rte_table_hash_params {
> > ...
> > union {
> >     rte_table_hash_op_hash  f_hash_4params;
> >     rte_hash_function f_hash_3_params;
> > };
> >
> > ?
> >
> 
> Yes, agreed, this is yet another way to handle this, thanks Konstantin.

Agree that this solution is a lot better than raw casting.

The issue I have with casting is that it doesn't explicitly show that the signature is different, and that the code must be aware of that fact. With a union, at least the code explicitly states that there is a difference in signature, and that this is being handled by the code, so this looks a better solution.

Neil proposed an alternative solution using a bit to indicate calling params in a separate reply - another possibility.




More information about the dev mailing list