* [dpdk-dev] [PATCH] pipeline: remove unreachable branch
@ 2021-11-03 6:56 David Marchand
2021-11-03 12:55 ` Dumitrescu, Cristian
0 siblings, 1 reply; 3+ messages in thread
From: David Marchand @ 2021-11-03 6:56 UTC (permalink / raw)
To: dev; +Cc: Cristian Dumitrescu, Xueqin Lin, Zhihong Peng
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.marchand@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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [dpdk-dev] [PATCH] pipeline: remove unreachable branch
2021-11-03 6:56 [dpdk-dev] [PATCH] pipeline: remove unreachable branch David Marchand
@ 2021-11-03 12:55 ` Dumitrescu, Cristian
2021-11-04 17:20 ` Thomas Monjalon
0 siblings, 1 reply; 3+ messages in thread
From: Dumitrescu, Cristian @ 2021-11-03 12:55 UTC (permalink / raw)
To: David Marchand, dev; +Cc: Lin, Xueqin, Peng, ZhihongX
> -----Original Message-----
> From: David Marchand <david.marchand@redhat.com>
> Sent: Wednesday, November 3, 2021 6:57 AM
> To: dev@dpdk.org
> Cc: Dumitrescu, Cristian <cristian.dumitrescu@intel.com>; Lin, Xueqin
> <xueqin.lin@intel.com>; Peng, ZhihongX <zhihongx.peng@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.marchand@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.dumitrescu@intel.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [dpdk-dev] [PATCH] pipeline: remove unreachable branch
2021-11-03 12:55 ` Dumitrescu, Cristian
@ 2021-11-04 17:20 ` Thomas Monjalon
0 siblings, 0 replies; 3+ messages in thread
From: Thomas Monjalon @ 2021-11-04 17:20 UTC (permalink / raw)
To: David Marchand; +Cc: dev, Lin, Xueqin, Peng, ZhihongX, Dumitrescu, Cristian
> > 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.marchand@redhat.com>
>
> Acked-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
Applied, thanks
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-11-04 17:20 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-03 6:56 [dpdk-dev] [PATCH] pipeline: remove unreachable branch David Marchand
2021-11-03 12:55 ` Dumitrescu, Cristian
2021-11-04 17:20 ` Thomas Monjalon
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).