[2/2] test/hash: fix coverity warning

Message ID 20221103181339.1135127-1-vladimir.medvedkin@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers
Series [1/2] test/hash: fix coverity warning |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK
ci/iol-intel-Functional success Functional Testing PASS
ci/intel-Testing success Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS
ci/github-robot: build success github build: passed
ci/iol-x86_64-unit-testing success Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-aarch64-unit-testing success Testing PASS

Commit Message

Vladimir Medvedkin Nov. 3, 2022, 6:13 p.m. UTC
  Check return value after bulk lookup

Coverity issue: 357746
Fixes: 14b8ab576235 ("hash: add bulk lookup with signatures array")
Cc: stable@dpdk.org

Signed-off-by: Vladimir Medvedkin <vladimir.medvedkin@intel.com>
---
 app/test/test_hash_perf.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
  

Comments

Stephen Hemminger Nov. 3, 2022, 6:33 p.m. UTC | #1
On Thu,  3 Nov 2022 18:13:38 +0000
Vladimir Medvedkin <vladimir.medvedkin@intel.com> wrote:

> +				if (ret != 0) {
> +					printf("rte_hash_lookup_with_hash_bulk"
> +						" failed with %d\n", ret);
> +					return -1;
> +				}

It makes it harder to search for error messages when they are split.
Ignore any checkpatch warnings about this.

Also, shouldn't test failures be printed on stderr rather than stdout?
  
Vladimir Medvedkin Nov. 3, 2022, 6:52 p.m. UTC | #2
Hi Stephen,

On 03/11/2022 18:33, Stephen Hemminger wrote:
> On Thu,  3 Nov 2022 18:13:38 +0000
> Vladimir Medvedkin <vladimir.medvedkin@intel.com> wrote:
>
>> +				if (ret != 0) {
>> +					printf("rte_hash_lookup_with_hash_bulk"
>> +						" failed with %d\n", ret);
>> +					return -1;
>> +				}
> It makes it harder to search for error messages when they are split.
> Ignore any checkpatch warnings about this.

Will fix, thanks!

>
> Also, shouldn't test failures be printed on stderr rather than stdout?

It seems that most of the tests print on stdout.
  

Patch

diff --git a/app/test/test_hash_perf.c b/app/test/test_hash_perf.c
index 5d36c0f454..a9655e69f7 100644
--- a/app/test/test_hash_perf.c
+++ b/app/test/test_hash_perf.c
@@ -475,6 +475,11 @@  timed_lookups_multi(unsigned int with_hash, unsigned int with_data,
 					(const void **)keys_burst,
 					&signatures[j * BURST_SIZE],
 					BURST_SIZE, positions_burst);
+				if (ret != 0) {
+					printf("rte_hash_lookup_with_hash_bulk"
+						" failed with %d\n", ret);
+					return -1;
+				}
 				for (k = 0; k < BURST_SIZE; k++) {
 					if (positions_burst[k] !=
 							positions[j *
@@ -487,10 +492,15 @@  timed_lookups_multi(unsigned int with_hash, unsigned int with_data,
 					}
 				}
 			} else {
-				rte_hash_lookup_bulk(h[table_index],
+				ret = rte_hash_lookup_bulk(h[table_index],
 						(const void **) keys_burst,
 						BURST_SIZE,
 						positions_burst);
+				if (ret != 0) {
+					printf("rte_hash_lookup_bulk"
+						" failed with %d\n", ret);
+					return -1;
+				}
 				for (k = 0; k < BURST_SIZE; k++) {
 					if (positions_burst[k] != positions[j * BURST_SIZE + k]) {
 						printf("Key looked up in %d, should be in %d\n",