[dpdk-dev] ethdev: fix CID 124557 unchecked return value

Message ID 1460029592-11964-1-git-send-email-slawomirx.mrozowicz@intel.com (mailing list archive)
State Accepted, archived
Headers

Commit Message

Slawomir Mrozowicz April 7, 2016, 11:46 a.m. UTC
  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(-)
  

Comments

Thomas Monjalon April 7, 2016, 5:09 p.m. UTC | #1
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 :)
  

Patch

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