> -----Original Message-----
> From: David Marchand <david.march...@redhat.com>
> Sent: Wednesday, November 3, 2021 6:57 AM
> To: dev@dpdk.org
> Cc: Dumitrescu, Cristian <cristian.dumitre...@intel.com>; Lin, Xueqin
> <xueqin....@intel.com>; Peng, ZhihongX <zhihongx.p...@intel.com>
> Subject: [PATCH] pipeline: remove unreachable branch
> 
> A previous change blamed it on compiler/ASan, while this is a real
> (yet minor) issue.
> 
> This return -EINVAL is never reached since we test all combinations of
> fidx and fcin booleans.
> All branches end up with a return 0, factorize them.
> 
> Fixes: 84f5ac9418ea ("pipeline: fix build with ASan")
> Fixes: f38913b7fb8e ("pipeline: add meter array to SWX")
> 
> Signed-off-by: David Marchand <david.march...@redhat.com>
> ---
> ---
>  lib/pipeline/rte_swx_pipeline.c | 10 +---------
>  1 file changed, 1 insertion(+), 9 deletions(-)
> 
> diff --git a/lib/pipeline/rte_swx_pipeline.c b/lib/pipeline/rte_swx_pipeline.c
> index 1afaffefd4..0bdda7e0b3 100644
> --- a/lib/pipeline/rte_swx_pipeline.c
> +++ b/lib/pipeline/rte_swx_pipeline.c
> @@ -4539,8 +4539,6 @@ instr_meter_translate(struct rte_swx_pipeline *p,
>               instr->meter.color_out.struct_id =
> (uint8_t)color_out_struct_id;
>               instr->meter.color_out.n_bits = fcout->n_bits;
>               instr->meter.color_out.offset = fcout->offset / 8;
> -
> -             return 0;
>       }
> 
>       /* index = HMEFT, length = HMEFT, color_in = I, color_out = MEF. */
> @@ -4575,8 +4573,6 @@ instr_meter_translate(struct rte_swx_pipeline *p,
>               instr->meter.color_out.struct_id =
> (uint8_t)color_out_struct_id;
>               instr->meter.color_out.n_bits = fcout->n_bits;
>               instr->meter.color_out.offset = fcout->offset / 8;
> -
> -             return 0;
>       }
> 
>       /* index = I, length = HMEFT, color_in = MEFT, color_out = MEF. */
> @@ -4607,8 +4603,6 @@ instr_meter_translate(struct rte_swx_pipeline *p,
>               instr->meter.color_out.struct_id =
> (uint8_t)color_out_struct_id;
>               instr->meter.color_out.n_bits = fcout->n_bits;
>               instr->meter.color_out.offset = fcout->offset / 8;
> -
> -             return 0;
>       }
> 
>       /* index = I, length = HMEFT, color_in = I, color_out = MEF. */
> @@ -4638,11 +4632,9 @@ instr_meter_translate(struct rte_swx_pipeline *p,
>               instr->meter.color_out.struct_id =
> (uint8_t)color_out_struct_id;
>               instr->meter.color_out.n_bits = fcout->n_bits;
>               instr->meter.color_out.offset = fcout->offset / 8;
> -
> -             return 0;
>       }
> 
> -     return -EINVAL;
> +     return 0;
>  }
> 
>  static inline void
> --
> 2.23.0

This is a great idea, thanks David!

I think it is a good compromise between keeping Coverity happy and preserving 
the code structure and readability, so

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

Reply via email to