[dpdk-dev,v3,21/24] rte_ethdev.h: explicit cast for truncation

Message ID 152609042788.121661.16333710243796218948.stgit@localhost.localdomain (mailing list archive)
State Accepted, archived
Delegated to: Thomas Monjalon
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Andy Green May 12, 2018, 2 a.m. UTC
  /projects/lagopus/src/dpdk/build/include/rte_ethdev.h:
In function 'rte_eth_tx_buffer_flush':
/projects/lagopus/src/dpdk/build/include/rte_ethdev.h:4248:55:
warning: conversion from 'int' to 'uint16_t'
{aka 'short unsigned int'} may change value [-Wconversion]
   buffer->error_callback(&buffer->pkts[sent], to_send - sent,

Signed-off-by: Andy Green <andy@warmcat.com>
---
 lib/librte_ethdev/rte_ethdev.h |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
  

Comments

Thomas Monjalon May 13, 2018, 8:43 p.m. UTC | #1
12/05/2018 04:00, Andy Green:
> /projects/lagopus/src/dpdk/build/include/rte_ethdev.h:
> In function 'rte_eth_tx_buffer_flush':
> /projects/lagopus/src/dpdk/build/include/rte_ethdev.h:4248:55:
> warning: conversion from 'int' to 'uint16_t'
> {aka 'short unsigned int'} may change value [-Wconversion]
>    buffer->error_callback(&buffer->pkts[sent], to_send - sent,

    Fixes: d6c99e62c852 ("ethdev: add buffered Tx")
    Cc: stable@dpdk.org

> Signed-off-by: Andy Green <andy@warmcat.com>

Applied, thanks
  

Patch

diff --git a/lib/librte_ethdev/rte_ethdev.h b/lib/librte_ethdev/rte_ethdev.h
index 2487e1d2d..2cb5fe3be 100644
--- a/lib/librte_ethdev/rte_ethdev.h
+++ b/lib/librte_ethdev/rte_ethdev.h
@@ -4245,8 +4245,9 @@  rte_eth_tx_buffer_flush(uint16_t port_id, uint16_t queue_id,
 
 	/* All packets sent, or to be dealt with by callback below */
 	if (unlikely(sent != to_send))
-		buffer->error_callback(&buffer->pkts[sent], to_send - sent,
-				buffer->error_userdata);
+		buffer->error_callback(&buffer->pkts[sent],
+				       (uint16_t)(to_send - sent),
+				       buffer->error_userdata);
 
 	return sent;
 }