[dpdk-dev,v2,16/30] net/mlx5: fix clang compilation error

Message ID 9603c091a45da3cec77a3122498777960b83b06a.1507207731.git.nelio.laranjeiro@6wind.com (mailing list archive)
State Changes Requested, archived
Delegated to: Ferruh Yigit
Headers

Checks

Context Check Description
ci/checkpatch warning coding style issues
ci/Intel-compilation fail apply patch file failure

Commit Message

Nélio Laranjeiro Oct. 5, 2017, 12:49 p.m. UTC
  drivers/net/mlx5/mlx5_rxq.c:606:6: error: comparison of constant 4
      with expression of type 'enum hash_rxq_flow_type' is always true
      [-Werror,-Wtautological-constant-out-of-range-compare]
                        i != (int)RTE_DIM((*priv->hash_rxqs)[0].special_flow);
                        ~ ^  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Clang expects to have an index going upto special_flow size which is
defined by MLX5_MAX_SPECIAL_FLOWS and value is 4.  Comparing to an
unrelated enum where index my be lower cause this compilation issue.

Fixes: 36351ea34b92 ("net/mlx: fix build with icc")
Cc: ferruh.yigit@intel.com
Cc: stable@dpdk.org

Signed-off-by: Nelio Laranjeiro <nelio.laranjeiro@6wind.com>
---
 drivers/net/mlx5/mlx5_rxq.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
  

Comments

Yongseok Koh Oct. 6, 2017, 5:01 a.m. UTC | #1
On Thu, Oct 05, 2017 at 02:49:48PM +0200, Nelio Laranjeiro wrote:
> drivers/net/mlx5/mlx5_rxq.c:606:6: error: comparison of constant 4
>       with expression of type 'enum hash_rxq_flow_type' is always true
>       [-Werror,-Wtautological-constant-out-of-range-compare]
>                         i != (int)RTE_DIM((*priv->hash_rxqs)[0].special_flow);
>                         ~ ^  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 
> Clang expects to have an index going upto special_flow size which is
> defined by MLX5_MAX_SPECIAL_FLOWS and value is 4.  Comparing to an
> unrelated enum where index my be lower cause this compilation issue.
> 
> Fixes: 36351ea34b92 ("net/mlx: fix build with icc")
> Cc: ferruh.yigit@intel.com
> Cc: stable@dpdk.org
> 
> Signed-off-by: Nelio Laranjeiro <nelio.laranjeiro@6wind.com>
> ---
Acked-by: Yongseok Koh <yskoh@mellanox.com>
 
Thanks
  

Patch

diff --git a/drivers/net/mlx5/mlx5_rxq.c b/drivers/net/mlx5/mlx5_rxq.c
index b240c16..81e9eb5 100644
--- a/drivers/net/mlx5/mlx5_rxq.c
+++ b/drivers/net/mlx5/mlx5_rxq.c
@@ -606,11 +606,9 @@  priv_allow_flow_type(struct priv *priv, enum hash_rxq_flow_type type)
 int
 priv_rehash_flows(struct priv *priv)
 {
-	enum hash_rxq_flow_type i;
+	size_t i;
 
-	for (i = HASH_RXQ_FLOW_TYPE_PROMISC;
-			i != RTE_DIM((*priv->hash_rxqs)[0].special_flow);
-			++i)
+	for (i = 0; i != RTE_DIM((*priv->hash_rxqs)[0].special_flow); ++i)
 		if (!priv_allow_flow_type(priv, i)) {
 			priv_special_flow_disable(priv, i);
 		} else {