Skip to contentSkip to conversation

test/compress: fix coverity warnings

PATCH Applied Adam Dybkowski 3 participants 5 messages Jul 23, 2019 – Jul 26, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 test/compress: fix coverity warnings

CID 340857: Null pointer dereferences (NULL_RETURNS)

CID 340856: (CONSTANT_EXPRESSION_RESULT)

Fixes 3be12ea52ad8 ("test/compress: improve debug trace setup")
---
 app/test/test_compressdev.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
app/test/test_compressdev.c +8 -2
index 65889c242..992eac8e0 100644
@@ -755,6 +755,12 @@ test_deflate_comp_decomp(const struct interim_data_params *int_data,
 	char *contig_buf = NULL;
 	uint64_t compress_checksum[num_bufs];
 
+	if (capa == NULL) {
+		RTE_LOG(ERR, USER1,
+			"Compress device does not support DEFLATE\n");
+		return -1;
+	}
+
 	/* Initialize all arrays to NULL */
 	memset(uncomp_bufs, 0, sizeof(struct rte_mbuf *) * num_bufs);
 	memset(comp_bufs, 0, sizeof(struct rte_mbuf *) * num_bufs);
@@ -975,7 +981,7 @@ test_deflate_comp_decomp(const struct interim_data_params *int_data,
 		enum rte_comp_huffman huffman_type =
 			compress_xform->deflate.huffman;
 		char engine[] = "zlib (directly, not PMD)";
-		if (zlib_dir != ZLIB_COMPRESS || zlib_dir != ZLIB_ALL)
+		if (zlib_dir != ZLIB_COMPRESS && zlib_dir != ZLIB_ALL)
 			strlcpy(engine, "PMD", sizeof(engine));
 
 		RTE_LOG(DEBUG, USER1, "Buffer %u compressed by %s from %u to"
@@ -1211,7 +1217,7 @@ test_deflate_comp_decomp(const struct interim_data_params *int_data,
 	for (i = 0; i < num_bufs; i++) {
 		priv_data = (struct priv_op_data *)(ops_processed[i] + 1);
 		char engine[] = "zlib, (directly, no PMD)";
-		if (zlib_dir != ZLIB_DECOMPRESS || zlib_dir != ZLIB_ALL)
+		if (zlib_dir != ZLIB_DECOMPRESS && zlib_dir != ZLIB_ALL)
 			strlcpy(engine, "pmd", sizeof(engine));
 		RTE_LOG(DEBUG, USER1,
 			"Buffer %u decompressed by %s from %u to %u bytes\n",
Signature · 1 line
2.17.1
#1 lore raw

Hi Adam,

Quoted 23 lines

-----Original Message-----
From: Dybkowski, AdamX
Sent: Tuesday, July 23, 2019 11:54 AM
To: [email protected]; Trahe, Fiona <[email protected]>; [email protected]
Cc: Dybkowski, AdamX <[email protected]>
Subject: [PATCH] test/compress: fix coverity warnings

CID 340857: Null pointer dereferences (NULL_RETURNS)

CID 340856: (CONSTANT_EXPRESSION_RESULT)

Fixes 3be12ea52ad8 ("test/compress: improve debug trace setup")
---
 app/test/test_compressdev.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
app/test/test_compressdev.c +0 -0
index 65889c242..992eac8e0 100644

app/test/test_compressdev.c test_deflate_comp_decomp(const struct interim_data_params *int_data, · line 761

Quoted 7 lines
app/test/test_compressdev.c +4 -0
@@ -755,6 +755,12 @@ test_deflate_comp_decomp(const struct interim_data_params *int_data,
 	char *contig_buf = NULL;
 	uint64_t compress_checksum[num_bufs];
 
+	if (capa == NULL) {
+		RTE_LOG(ERR, USER1,
+			"Compress device does not support DEFLATE\n");
+		return -1;

[Fiona] shouldn't you return -ENOTSUP?

#2 lore raw

Hi Fiona.

Quoted 35 lines

-----Original Message-----
From: Trahe, Fiona
Sent: Thursday, 25 July, 2019 15:56
To: Dybkowski, AdamX <[email protected]>; [email protected]; [email protected]
Cc: Trahe, Fiona <[email protected]>
Subject: RE: [PATCH] test/compress: fix coverity warnings

Hi Adam,

app/test/test_compressdev.c test_deflate_comp_decomp(const struct

Quoted 24 lines

-----Original Message-----
From: Dybkowski, AdamX
Sent: Tuesday, July 23, 2019 11:54 AM
To: [email protected]; Trahe, Fiona <[email protected]>; [email protected]
Cc: Dybkowski, AdamX <[email protected]>
Subject: [PATCH] test/compress: fix coverity warnings

CID 340857: Null pointer dereferences (NULL_RETURNS)

CID 340856: (CONSTANT_EXPRESSION_RESULT)

Fixes 3be12ea52ad8 ("test/compress: improve debug trace setup")
---
 app/test/test_compressdev.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
app/test/test_compressdev.c +0 -0
index 65889c242..992eac8e0 100644
@@ -755,6 +755,12 @@ test_deflate_comp_decomp(const struct

interim_data_params *int_data,

Quoted 8 lines

app/test/test_compressdev.c test_deflate_comp_decomp(const struct interim_data_params *int_data, · line 761

Quoted 7 lines
app/test/test_compressdev.c +4 -0
 	char *contig_buf = NULL;
 	uint64_t compress_checksum[num_bufs];
 
+	if (capa == NULL) {
+		RTE_LOG(ERR, USER1,
+			"Compress device does not support DEFLATE\n");
+		return -1;

[Fiona] shouldn't you return -ENOTSUP?

[Adam] All other errors end with returning -1 (see the ret_status variable which is initialized to -1). That's why I handle the error case the same way. This is inside the test suite, not a PMD.

Acked-by
#3 lore raw

Hi Adam,

Quoted 46 lines

-----Original Message-----
From: Dybkowski, AdamX
Sent: Thursday, July 25, 2019 3:23 PM
To: Trahe, Fiona <[email protected]>; [email protected]; [email protected]
Subject: RE: [PATCH] test/compress: fix coverity warnings

Hi Fiona.

Quoted 38 lines

-----Original Message-----
From: Trahe, Fiona
Sent: Thursday, 25 July, 2019 15:56
To: Dybkowski, AdamX <[email protected]>; [email protected]; [email protected]
Cc: Trahe, Fiona <[email protected]>
Subject: RE: [PATCH] test/compress: fix coverity warnings

Hi Adam,

app/test/test_compressdev.c test_deflate_comp_decomp(const struct

Quoted 24 lines

-----Original Message-----
From: Dybkowski, AdamX
Sent: Tuesday, July 23, 2019 11:54 AM
To: [email protected]; Trahe, Fiona <[email protected]>; [email protected]
Cc: Dybkowski, AdamX <[email protected]>
Subject: [PATCH] test/compress: fix coverity warnings

CID 340857: Null pointer dereferences (NULL_RETURNS)

CID 340856: (CONSTANT_EXPRESSION_RESULT)

Fixes 3be12ea52ad8 ("test/compress: improve debug trace setup")
---
 app/test/test_compressdev.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
app/test/test_compressdev.c +0 -0
index 65889c242..992eac8e0 100644
@@ -755,6 +755,12 @@ test_deflate_comp_decomp(const struct

interim_data_params *int_data,

Quoted 3 lines
app/test/test_compressdev.c +0 -0
 	char *contig_buf = NULL;
 	uint64_t compress_checksum[num_bufs];
 
Quoted 7 lines
Quoted 5 lines

app/test/test_compressdev.c test_deflate_comp_decomp(const struct interim_data_params *int_data, · line 761

Quoted 4 lines
app/test/test_compressdev.c +4 -0
+	if (capa == NULL) {
+		RTE_LOG(ERR, USER1,
+			"Compress device does not support DEFLATE\n");
+		return -1;

[Fiona] shouldn't you return -ENOTSUP?

[Adam] All other errors end with returning -1 (see the ret_status variable which is initialized to -1). That's why I handle the error case the same way. This is inside the test suite, not a PMD.

[Fiona] ok, can see in the code that the capability is already checked at the higher level for this case, so no need to return ENOTSUP here. -1 is ok

Applied
#4 lore raw
Quoted 26 lines
Quoted 26 lines
Quoted 26 lines

app/test/test_compressdev.c test_deflate_comp_decomp(const struct

Quoted 17 lines

CID 340857: Null pointer dereferences (NULL_RETURNS)

CID 340856: (CONSTANT_EXPRESSION_RESULT)

Fixes 3be12ea52ad8 ("test/compress: improve debug trace setup")
---
 app/test/test_compressdev.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
app/test/test_compressdev.c +0 -0
index 65889c242..992eac8e0 100644
@@ -755,6 +755,12 @@ test_deflate_comp_decomp(const struct

interim_data_params *int_data,

app/test/test_compressdev.c test_deflate_comp_decomp(const struct interim_data_params *int_data, · line 761

Quoted 7 lines
app/test/test_compressdev.c +4 -0
 	char *contig_buf = NULL;
 	uint64_t compress_checksum[num_bufs];
 
+	if (capa == NULL) {
+		RTE_LOG(ERR, USER1,
+			"Compress device does not support DEFLATE\n");
+		return -1;

[Fiona] shouldn't you return -ENOTSUP?

Quoted 8 lines
Quoted 1 line

[Adam] All other errors end with returning -1 (see the ret_status variable which

is initialized to -1).

Quoted 1 line

That's why I handle the error case the same way. This is inside the test suite,

not a PMD.
[Fiona] ok, can see in the code that the capability is already checked at the higher level
for this case, so no need to return ENOTSUP here. -1 is ok

Applied to dpdk-next-crypto

Thanks.