On 05/14/2018 12:54 AM, Thomas Monjalon wrote:
12/05/2018 03:59, Andy Green:
@@ -836,8 +836,9 @@ rte_mbuf_refcnt_update(struct rte_mbuf *m, int16_t value)
* reference counter can occur.
*/
if (likely(rte_mbuf_refcnt_read(m) == 1)) {
- rte_mbuf_refcnt_set(m, 1 + value);
- return 1 + value;
+ ++value;
+ rte_mbuf_refcnt_set(m, value);
+ return value;
}
I don't understand what it is fixing.
Please could you explain or show the GCC warning?
"1 + value", where value is an uint16_t causes promotion to a signed
int. The compiler complained that we are shoving an int into a uint16_t
return type with different size and sign.
Bumping and returning value directly instead removes the promotion and
the problem.
I added this explanation to the patch (although the title gave a big
clue already).
-Andy