DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] ethdev: fix CID 124557 unchecked return value
@ 2016-04-07 11:46 Slawomir Mrozowicz
  2016-04-07 17:09 ` Thomas Monjalon
  0 siblings, 1 reply; 2+ messages in thread
From: Slawomir Mrozowicz @ 2016-04-07 11:46 UTC (permalink / raw)
  To: thomas.monjalon; +Cc: dev, Slawomir Mrozowicz

It fix coverity issue:
CID 124557 (#1 of 1): Unchecked return value (CHECKED_RETURN)
3. check_return: Calling rte_eth_tx_buffer_set_err_callback without checking return value (as is done elsewhere 6 out of 7 times).

Fixes: d6c99e62c852 ("ethdev: add buffered Tx")
Signed-off-by: Slawomir Mrozowicz <slawomirx.mrozowicz@intel.com>
---
 lib/librte_ether/rte_ethdev.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index dcf9e6f..0dc1025 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -1342,15 +1342,19 @@ rte_eth_tx_buffer_set_err_callback(struct rte_eth_dev_tx_buffer *buffer,
 int
 rte_eth_tx_buffer_init(struct rte_eth_dev_tx_buffer *buffer, uint16_t size)
 {
+	int ret_val = 0;
+
 	if (buffer == NULL)
 		return -EINVAL;
 
 	buffer->size = size;
-	if (buffer->error_callback == NULL)
-		rte_eth_tx_buffer_set_err_callback(buffer,
-				rte_eth_tx_buffer_drop_callback, NULL);
+	if (buffer->error_callback == NULL) {
 
-	return 0;
+		ret_val = rte_eth_tx_buffer_set_err_callback(
+			buffer, rte_eth_tx_buffer_drop_callback, NULL);
+	}
+
+	return ret_val;
 }
 
 void
-- 
1.9.1

--------------------------------------------------------------------

Intel Technology Poland sp. z o.o.
ul. Slowackiego 173 | 80-298 Gdansk | Sad Rejonowy Gdansk Polnoc | VII Wydzial Gospodarczy Krajowego Rejestru Sadowego - KRS 101882 | NIP 957-07-52-316 | Kapital zakladowy 200.000 PLN.

Ta wiadomosc wraz z zalacznikami jest przeznaczona dla okreslonego adresata i moze zawierac informacje poufne. W razie przypadkowego otrzymania tej wiadomosci, prosimy o powiadomienie nadawcy oraz trwale jej usuniecie; jakiekolwiek
przegladanie lub rozpowszechnianie jest zabronione.
This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). If you are not the intended recipient, please contact the sender and delete all copies; any review or distribution by
others is strictly prohibited.

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [dpdk-dev] [PATCH] ethdev: fix CID 124557 unchecked return value
  2016-04-07 11:46 [dpdk-dev] [PATCH] ethdev: fix CID 124557 unchecked return value Slawomir Mrozowicz
@ 2016-04-07 17:09 ` Thomas Monjalon
  0 siblings, 0 replies; 2+ messages in thread
From: Thomas Monjalon @ 2016-04-07 17:09 UTC (permalink / raw)
  To: Slawomir Mrozowicz; +Cc: dev

2016-04-07 13:46, Slawomir Mrozowicz:
> It fix coverity issue:
> CID 124557 (#1 of 1): Unchecked return value (CHECKED_RETURN)
> 3. check_return: Calling rte_eth_tx_buffer_set_err_callback without checking return value (as is done elsewhere 6 out of 7 times).

Lines must be wrapped.

> Fixes: d6c99e62c852 ("ethdev: add buffered Tx")
> Signed-off-by: Slawomir Mrozowicz <slawomirx.mrozowicz@intel.com>
|...]
|> --- a/lib/librte_ether/rte_ethdev.c
> +++ b/lib/librte_ether/rte_ethdev.c
> @@ -1342,15 +1342,19 @@ rte_eth_tx_buffer_set_err_callback(struct rte_eth_dev_tx_buffer *buffer,
>  int
>  rte_eth_tx_buffer_init(struct rte_eth_dev_tx_buffer *buffer, uint16_t size)
>  {
> +	int ret_val = 0;

The name "ret" is more common in this file.

> +
>  	if (buffer == NULL)
>  		return -EINVAL;
>  
>  	buffer->size = size;
> -	if (buffer->error_callback == NULL)
> -		rte_eth_tx_buffer_set_err_callback(buffer,
> -				rte_eth_tx_buffer_drop_callback, NULL);
> +	if (buffer->error_callback == NULL) {
>  

This blank line can be removed.

> -	return 0;
> +		ret_val = rte_eth_tx_buffer_set_err_callback(
> +			buffer, rte_eth_tx_buffer_drop_callback, NULL);
> +	}
> +
> +	return ret_val;
>  }

Applied with above small changes, thanks and welcome :)

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-04-07 17:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-07 11:46 [dpdk-dev] [PATCH] ethdev: fix CID 124557 unchecked return value Slawomir Mrozowicz
2016-04-07 17:09 ` 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).