[2/3] app/test_bpf: don't print eBPF program if NULL

Message ID 20220210230906.833163-3-stephen@networkplumber.org (mailing list archive)
State Accepted, archived
Delegated to: Thomas Monjalon
Headers
Series small fixes suggested by Coverity scan |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Stephen Hemminger Feb. 10, 2022, 11:09 p.m. UTC
  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

Ananyev, Konstantin Feb. 11, 2022, 11:02 a.m. UTC | #1
> 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
  

Patch

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