net/mlx5: fix clang 3.4.2 compilation

Message ID 1579703770-30091-1-git-send-email-matan@mellanox.com (mailing list archive)
State Accepted, archived
Delegated to: Raslan Darawsheh
Headers
Series net/mlx5: fix clang 3.4.2 compilation |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/iol-intel-Performance fail Performance Testing issues
ci/iol-testing success Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-nxp-Performance success Performance Testing PASS
ci/travis-robot success Travis build: passed
ci/Intel-compilation success Compilation OK

Commit Message

Matan Azrad Jan. 22, 2020, 2:36 p.m. UTC
  Compilation massage example:
"dpdk/drivers/net/mlx5/mlx5_flow_dv.c:1087:10: error: comparison of
unsigned enum expression < 0 is always false
[-Werror,-Wtautological-compare]
        if (reg < 0)
            ~~~ ^ ~
"

enum modify_reg holds only non-negative integers and in some places in
the code it was used to be compared with negative value, hence
compilation was failed.

Change all thus places to use integer instead of enum modify_reg.

Fixes: 3e8edd0ef848 ("net/mlx5: update metadata register ID query")
Fixes: 55deee1715f0 ("net/mlx5: extend flow mark support")
Cc: stable@dpdk.org

Signed-off-by: Matan Azrad <matan@mellanox.com>
---
 drivers/net/mlx5/mlx5_flow.c    |  2 +-
 drivers/net/mlx5/mlx5_flow.h    |  2 +-
 drivers/net/mlx5/mlx5_flow_dv.c | 12 ++++++------
 3 files changed, 8 insertions(+), 8 deletions(-)
  

Comments

Raslan Darawsheh Jan. 26, 2020, 4:03 p.m. UTC | #1
Hi,

> -----Original Message-----
> From: dev <dev-bounces@dpdk.org> On Behalf Of Matan Azrad
> Sent: Wednesday, January 22, 2020 4:36 PM
> To: Slava Ovsiienko <viacheslavo@mellanox.com>
> Cc: dev@dpdk.org; stable@dpdk.org
> Subject: [dpdk-dev] [PATCH] net/mlx5: fix clang 3.4.2 compilation
> 
> Compilation massage example:
> "dpdk/drivers/net/mlx5/mlx5_flow_dv.c:1087:10: error: comparison of
> unsigned enum expression < 0 is always false
> [-Werror,-Wtautological-compare]
>         if (reg < 0)
>             ~~~ ^ ~
> "
> 
> enum modify_reg holds only non-negative integers and in some places in
> the code it was used to be compared with negative value, hence
> compilation was failed.
> 
> Change all thus places to use integer instead of enum modify_reg.
> 
> Fixes: 3e8edd0ef848 ("net/mlx5: update metadata register ID query")
> Fixes: 55deee1715f0 ("net/mlx5: extend flow mark support")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Matan Azrad <matan@mellanox.com>
> ---
>  drivers/net/mlx5/mlx5_flow.c    |  2 +-
>  drivers/net/mlx5/mlx5_flow.h    |  2 +-
>  drivers/net/mlx5/mlx5_flow_dv.c | 12 ++++++------
>  3 files changed, 8 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c
> index 970123b..441ca10 100644
> --- a/drivers/net/mlx5/mlx5_flow.c
> +++ b/drivers/net/mlx5/mlx5_flow.c
> @@ -341,7 +341,7 @@ struct mlx5_flow_tunnel_info {
>   *   The request register on success, a negative errno
>   *   value otherwise and rte_errno is set.
>   */
> -enum modify_reg
> +int
>  mlx5_flow_get_reg_id(struct rte_eth_dev *dev,
>  		     enum mlx5_feature_name feature,
>  		     uint32_t id,
> diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h
> index 9832542..886d770 100644
> --- a/drivers/net/mlx5/mlx5_flow.h
> +++ b/drivers/net/mlx5/mlx5_flow.h
> @@ -762,7 +762,7 @@ uint64_t mlx5_flow_hashfields_adjust(struct
> mlx5_flow *dev_flow, int tunnel,
>  				     uint64_t hash_fields);
>  uint32_t mlx5_flow_adjust_priority(struct rte_eth_dev *dev, int32_t
> priority,
>  				   uint32_t subpriority);
> -enum modify_reg mlx5_flow_get_reg_id(struct rte_eth_dev *dev,
> +int mlx5_flow_get_reg_id(struct rte_eth_dev *dev,
>  				     enum mlx5_feature_name feature,
>  				     uint32_t id,
>  				     struct rte_flow_error *error);
> diff --git a/drivers/net/mlx5/mlx5_flow_dv.c
> b/drivers/net/mlx5/mlx5_flow_dv.c
> index 5a1b426..0464fa8 100644
> --- a/drivers/net/mlx5/mlx5_flow_dv.c
> +++ b/drivers/net/mlx5/mlx5_flow_dv.c
> @@ -1077,7 +1077,7 @@ struct field_modify_info modify_tcp[] = {
>  		{4, 0, 0}, /* dynamic instead of
> MLX5_MODI_META_REG_C_1. */
>  		{0, 0, 0},
>  	};
> -	enum modify_reg reg;
> +	int reg;
> 
>  	if (!mask)
>  		return rte_flow_error_set(error, EINVAL,
> @@ -1119,7 +1119,7 @@ struct field_modify_info modify_tcp[] = {
>  			 const struct rte_flow_attr *attr,
>  			 struct rte_flow_error *error)
>  {
> -	enum modify_reg reg =
> +	int reg =
>  		mlx5_flow_get_reg_id(dev, attr->transfer ?
>  					  MLX5_METADATA_FDB :
>  					    attr->egress ?
> @@ -1167,7 +1167,7 @@ struct field_modify_info modify_tcp[] = {
>  	struct field_modify_info reg_c_x[] = {
>  		[1] = {0, 0, 0},
>  	};
> -	enum modify_reg reg = flow_dv_get_metadata_reg(dev, attr,
> error);
> +	int reg = flow_dv_get_metadata_reg(dev, attr, error);
> 
>  	if (reg < 0)
>  		return reg;
> @@ -1370,7 +1370,7 @@ struct field_modify_info modify_tcp[] = {
>  	struct rte_flow_item_meta nic_mask = {
>  		.data = UINT32_MAX
>  	};
> -	enum modify_reg reg;
> +	int reg;
>  	int ret;
> 
>  	if (!spec)
> @@ -2036,7 +2036,7 @@ struct field_modify_info modify_tcp[] = {
>  {
>  	const struct rte_flow_action_set_meta *conf;
>  	uint32_t nic_mask = UINT32_MAX;
> -	enum modify_reg reg;
> +	int reg;
> 
>  	if (!mlx5_flow_ext_mreg_supported(dev))
>  		return rte_flow_error_set(error, ENOTSUP,
> @@ -6124,7 +6124,7 @@ struct field_modify_info modify_tcp[] = {
>  		meta_m = &rte_flow_item_meta_mask;
>  	meta_v = (const void *)item->spec;
>  	if (meta_v) {
> -		enum modify_reg reg;
> +		int reg;
>  		uint32_t value = meta_v->data;
>  		uint32_t mask = meta_m->data;
> 
> --
> 1.8.3.1


Patches applied to next-net-mlx,

Kindest regards,
Raslan Darawsheh
  

Patch

diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c
index 970123b..441ca10 100644
--- a/drivers/net/mlx5/mlx5_flow.c
+++ b/drivers/net/mlx5/mlx5_flow.c
@@ -341,7 +341,7 @@  struct mlx5_flow_tunnel_info {
  *   The request register on success, a negative errno
  *   value otherwise and rte_errno is set.
  */
-enum modify_reg
+int
 mlx5_flow_get_reg_id(struct rte_eth_dev *dev,
 		     enum mlx5_feature_name feature,
 		     uint32_t id,
diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h
index 9832542..886d770 100644
--- a/drivers/net/mlx5/mlx5_flow.h
+++ b/drivers/net/mlx5/mlx5_flow.h
@@ -762,7 +762,7 @@  uint64_t mlx5_flow_hashfields_adjust(struct mlx5_flow *dev_flow, int tunnel,
 				     uint64_t hash_fields);
 uint32_t mlx5_flow_adjust_priority(struct rte_eth_dev *dev, int32_t priority,
 				   uint32_t subpriority);
-enum modify_reg mlx5_flow_get_reg_id(struct rte_eth_dev *dev,
+int mlx5_flow_get_reg_id(struct rte_eth_dev *dev,
 				     enum mlx5_feature_name feature,
 				     uint32_t id,
 				     struct rte_flow_error *error);
diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c
index 5a1b426..0464fa8 100644
--- a/drivers/net/mlx5/mlx5_flow_dv.c
+++ b/drivers/net/mlx5/mlx5_flow_dv.c
@@ -1077,7 +1077,7 @@  struct field_modify_info modify_tcp[] = {
 		{4, 0, 0}, /* dynamic instead of MLX5_MODI_META_REG_C_1. */
 		{0, 0, 0},
 	};
-	enum modify_reg reg;
+	int reg;
 
 	if (!mask)
 		return rte_flow_error_set(error, EINVAL,
@@ -1119,7 +1119,7 @@  struct field_modify_info modify_tcp[] = {
 			 const struct rte_flow_attr *attr,
 			 struct rte_flow_error *error)
 {
-	enum modify_reg reg =
+	int reg =
 		mlx5_flow_get_reg_id(dev, attr->transfer ?
 					  MLX5_METADATA_FDB :
 					    attr->egress ?
@@ -1167,7 +1167,7 @@  struct field_modify_info modify_tcp[] = {
 	struct field_modify_info reg_c_x[] = {
 		[1] = {0, 0, 0},
 	};
-	enum modify_reg reg = flow_dv_get_metadata_reg(dev, attr, error);
+	int reg = flow_dv_get_metadata_reg(dev, attr, error);
 
 	if (reg < 0)
 		return reg;
@@ -1370,7 +1370,7 @@  struct field_modify_info modify_tcp[] = {
 	struct rte_flow_item_meta nic_mask = {
 		.data = UINT32_MAX
 	};
-	enum modify_reg reg;
+	int reg;
 	int ret;
 
 	if (!spec)
@@ -2036,7 +2036,7 @@  struct field_modify_info modify_tcp[] = {
 {
 	const struct rte_flow_action_set_meta *conf;
 	uint32_t nic_mask = UINT32_MAX;
-	enum modify_reg reg;
+	int reg;
 
 	if (!mlx5_flow_ext_mreg_supported(dev))
 		return rte_flow_error_set(error, ENOTSUP,
@@ -6124,7 +6124,7 @@  struct field_modify_info modify_tcp[] = {
 		meta_m = &rte_flow_item_meta_mask;
 	meta_v = (const void *)item->spec;
 	if (meta_v) {
-		enum modify_reg reg;
+		int reg;
 		uint32_t value = meta_v->data;
 		uint32_t mask = meta_m->data;