[v12,3/4] Code changes to avoid the ASan error

Message ID 20211019135841.2004819-3-zhihongx.peng@intel.com (mailing list archive)
State Superseded, archived
Headers
Series [v12,1/4] Enable ASan Address Sanitization |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Peng, ZhihongX Oct. 19, 2021, 1:58 p.m. UTC
  From: Zhihong Peng <zhihongx.peng@intel.com>

Code changes to avoid the following ASan error:
"Control reaches end of non-void function".

Cc: cristian.dumitrescu@intel.com

Signed-off-by: Xueqin Lin <xueqin.lin@intel.com>
Signed-off-by: Zhihong Peng <zhihongx.peng@intel.com>
---
v7: no change.
v8: no change.
v9: Modify the submit log.
v10:no change.
v11:no change.
v12:Modify the commit log.
---
 lib/pipeline/rte_swx_pipeline.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
  

Comments

Cristian Dumitrescu Oct. 19, 2021, 2:05 p.m. UTC | #1
> -----Original Message-----
> From: Peng, ZhihongX <zhihongx.peng@intel.com>
> Sent: Tuesday, October 19, 2021 2:59 PM
> To: david.marchand@redhat.com; Burakov, Anatoly
> <anatoly.burakov@intel.com>; Ananyev, Konstantin
> <konstantin.ananyev@intel.com>; stephen@networkplumber.org;
> Dumitrescu, Cristian <cristian.dumitrescu@intel.com>; Mcnamara, John
> <john.mcnamara@intel.com>; Richardson, Bruce
> <bruce.richardson@intel.com>
> Cc: dev@dpdk.org; Lin, Xueqin <xueqin.lin@intel.com>; Peng, ZhihongX
> <zhihongx.peng@intel.com>
> Subject: [PATCH v12 3/4] Code changes to avoid the ASan error
> 
> From: Zhihong Peng <zhihongx.peng@intel.com>
> 
> Code changes to avoid the following ASan error:
> "Control reaches end of non-void function".
> 
> Cc: cristian.dumitrescu@intel.com
> 
> Signed-off-by: Xueqin Lin <xueqin.lin@intel.com>
> Signed-off-by: Zhihong Peng <zhihongx.peng@intel.com>
> ---
> v7: no change.
> v8: no change.
> v9: Modify the submit log.
> v10:no change.
> v11:no change.
> v12:Modify the commit log.
> ---
>  lib/pipeline/rte_swx_pipeline.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/lib/pipeline/rte_swx_pipeline.c b/lib/pipeline/rte_swx_pipeline.c
> index 1cd09a4b44..0acd6c6752 100644
> --- a/lib/pipeline/rte_swx_pipeline.c
> +++ b/lib/pipeline/rte_swx_pipeline.c
> @@ -4642,7 +4642,7 @@ instr_meter_translate(struct rte_swx_pipeline *p,
>  		return 0;
>  	}
> 
> -	CHECK(0, EINVAL);
> +	return -EINVAL;
>  }
> 
>  static inline void
> @@ -5937,7 +5937,7 @@ instr_translate(struct rte_swx_pipeline *p,
>  					      instr,
>  					      data);
> 
> -	CHECK(0, EINVAL);
> +	return -EINVAL;
>  }
> 
>  static struct instruction_data *
> --
> 2.25.1


This patch changes code working correctly just to please the tool. We should look at ways to fix the tooll, as this is likely going to be a recurring issue.

Hopefully this tool is to provide value to DPDK users.

Reluctantly,

Acked-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
  

Patch

diff --git a/lib/pipeline/rte_swx_pipeline.c b/lib/pipeline/rte_swx_pipeline.c
index 1cd09a4b44..0acd6c6752 100644
--- a/lib/pipeline/rte_swx_pipeline.c
+++ b/lib/pipeline/rte_swx_pipeline.c
@@ -4642,7 +4642,7 @@  instr_meter_translate(struct rte_swx_pipeline *p,
 		return 0;
 	}
 
-	CHECK(0, EINVAL);
+	return -EINVAL;
 }
 
 static inline void
@@ -5937,7 +5937,7 @@  instr_translate(struct rte_swx_pipeline *p,
 					      instr,
 					      data);
 
-	CHECK(0, EINVAL);
+	return -EINVAL;
 }
 
 static struct instruction_data *