From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.warmcat.com (mail.warmcat.com [163.172.24.82]) by dpdk.org (Postfix) with ESMTP id 3B8021BC54 for ; Mon, 14 May 2018 01:27:31 +0200 (CEST) To: Thomas Monjalon Cc: dev@dpdk.org References: <152609021699.121661.5295227351721865436.stgit@localhost.localdomain> <152609037755.121661.8441874507300238825.stgit@localhost.localdomain> <54513581.bBxl9oTBcb@xps> From: Andy Green Message-ID: <7893b885-db51-dd98-bf76-398571082b66@warmcat.com> Date: Mon, 14 May 2018 07:27:25 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 In-Reply-To: <54513581.bBxl9oTBcb@xps> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH v3 11/24] rte_mbuf.h: avoid warnings from inadvertant promotion X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 13 May 2018 23:27:31 -0000 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 >