[2/3] app/test_bpf: don't print eBPF program if NULL
Checks
Commit Message
If conversion of cBPF to eBPF fails (in rte_bpf_convert)
then the test should not try and print the result.
Coverity issue: 373661
Fixes: 2eccf6afbea9 ("bpf: add function to convert classic BPF to DPDK BPF")
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
app/test/test_bpf.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
Comments
> If conversion of cBPF to eBPF fails (in rte_bpf_convert)
> then the test should not try and print the result.
>
> Coverity issue: 373661
> Fixes: 2eccf6afbea9 ("bpf: add function to convert classic BPF to DPDK BPF")
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> ---
> app/test/test_bpf.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/app/test/test_bpf.c b/app/test/test_bpf.c
> index d1e10adab545..805cce640667 100644
> --- a/app/test/test_bpf.c
> +++ b/app/test/test_bpf.c
> @@ -3273,8 +3273,10 @@ test_bpf_dump(struct bpf_program *cbf, const struct rte_bpf_prm *prm)
> printf("cBPF program (%u insns)\n", cbf->bf_len);
> bpf_dump(cbf, 1);
>
> - printf("\neBPF program (%u insns)\n", prm->nb_ins);
> - rte_bpf_dump(stdout, prm->ins, prm->nb_ins);
> + if (prm != NULL) {
> + printf("\neBPF program (%u insns)\n", prm->nb_ins);
> + rte_bpf_dump(stdout, prm->ins, prm->nb_ins);
> + }
> }
>
> static int
> --
Acked-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
> 2.34.1
@@ -3273,8 +3273,10 @@ test_bpf_dump(struct bpf_program *cbf, const struct rte_bpf_prm *prm)
printf("cBPF program (%u insns)\n", cbf->bf_len);
bpf_dump(cbf, 1);
- printf("\neBPF program (%u insns)\n", prm->nb_ins);
- rte_bpf_dump(stdout, prm->ins, prm->nb_ins);
+ if (prm != NULL) {
+ printf("\neBPF program (%u insns)\n", prm->nb_ins);
+ rte_bpf_dump(stdout, prm->ins, prm->nb_ins);
+ }
}
static int