From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f66.google.com (mail-wm0-f66.google.com [74.125.82.66]) by dpdk.org (Postfix) with ESMTP id 4B2912D13 for ; Wed, 23 May 2018 14:11:07 +0200 (CEST) Received: by mail-wm0-f66.google.com with SMTP id m129-v6so8497003wmb.3 for ; Wed, 23 May 2018 05:11:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=oM1bkvRhfHHr9JvRSfIEo/pc65ygQwug36Qq6ZsHpus=; b=oUBs2pl0hYCHufNeqlNMfpMEx1H+5kQLrdbcuWbdzNiX3MIvxuC96j5XTLQOaFCn5y 3AW1r3IIvUyHCHkyG3F/zUuoOBcgKVfaJrE9PY6MazGa6cegt9OCokcXmt/MDyjHcvp9 exSCzxFKo5CuKgkirOC+09m2yWbyzTaCmT8SM86gONqPdd38AfZZRgdR1FgszyUmKHZR K5So+/aCsaW5RMQiGT5PtyVcQXL/ibjySZhOSzQn6t/ykHBgyCSv2Z4a7kLTjNi06NsM MZcbzF4CaAXa0TpYK4BM3khFUo7wutoXEllTGt2Kv73EuCXt9Jtgxvqir/BKyHnv8+9O b6TA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=oM1bkvRhfHHr9JvRSfIEo/pc65ygQwug36Qq6ZsHpus=; b=g92jIHAqBmfutgSc0eJfo2aQlEyLZk4PPg5Elz5Dd+QfICWvJq8SzPAmry6y+Bnskm 5DaWrcGbg7/aAGZauZnSfhnx0f0AaE0ERZadFmTb/LPgQAcuvBRMHbYkL6CsaItjAwPY 1Ll3+X0GtMn0GztgHCo/TXcr/zEv8lL02Zi3ceWpw2+8EkpE9udcmKC1AntFEhdObSyD jyhp13cZhkP16aAlHASPn+Pr3bRxlfrryP1+TfjnY8pi59r118f4Co8xbnEiPfUJzBBO 56hLr8GnptrBIIhoXxL272qhubCATAyJAa9y9xrKME7uwzvsU6vvhFIODayIpPGaSdaN RlBQ== X-Gm-Message-State: ALKqPwc6Qlx/Dku755NTbQwraVt9gwZBAkeULIGovDeAePvejPOXkcd1 o7sFRdrW1xulLit8582Zx3cxJ7S+E8A= X-Google-Smtp-Source: AB8JxZrXxKSjRvef/ZXUvhpn3F2G0+1Kz18Yj/4VxjH7Ooga0YznXOeFU7IwuBlyr8RjRctHaVqtMA== X-Received: by 2002:a1c:2703:: with SMTP id n3-v6mr3899248wmn.109.1527077466996; Wed, 23 May 2018 05:11:06 -0700 (PDT) Received: from localhost ([2a00:23c5:be9a:5200:ce4c:82c0:d567:ecbb]) by smtp.gmail.com with ESMTPSA id g75-v6sm3029679wmd.15.2018.05.23.05.11.06 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 23 May 2018 05:11:06 -0700 (PDT) From: luca.boccassi@gmail.com To: Andy Green Cc: Bruce Richardson , dpdk stable Date: Wed, 23 May 2018 13:09:42 +0100 Message-Id: <20180523121010.8385-31-luca.boccassi@gmail.com> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20180523121010.8385-1-luca.boccassi@gmail.com> References: <20180516101323.2234-2-luca.boccassi@gmail.com> <20180523121010.8385-1-luca.boccassi@gmail.com> Subject: [dpdk-stable] patch 'mbuf: avoid integer promotion in prepend/adj/chain' has been queued to stable release 18.02.2 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 23 May 2018 12:11:07 -0000 Hi, FYI, your patch has been queued to stable release 18.02.2 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 05/25/18. So please shout if anyone has objections. Thanks. Luca Boccassi --- >>From f622d2e35942e94e43746ef9f1fe64f4a0f54a4b Mon Sep 17 00:00:00 2001 From: Andy Green Date: Tue, 22 May 2018 09:24:42 +0800 Subject: [PATCH] mbuf: avoid integer promotion in prepend/adj/chain [ upstream commit 9d0b59f84e1170b12a128cdcccab5711f25b5dd8 ] GCC 8.1 warned: In function 'rte_pktmbuf_prepend': rte_mbuf.h:1908:17: warning: conversion from 'int' to 'uint16_t' {aka 'short unsigned int'} may change value [-Wconversion] m->data_off -= len; ^~~ m->data_off is a uint16_t uint16_t data_off; len (a uint16_t) is promoted to an int using -=. Do the subtraction explicitly and cast the result to uint16_t. The below += or -= changes are solving the same thing. In function 'rte_pktmbuf_adj': rte_mbuf.h:1969:17: warning: conversion from 'int' to 'uint16_t' {aka 'short unsigned int'} may change value [-Wconversion] m->data_off += len; ^~~ In function 'rte_pktmbuf_chain': rte_mbuf.h:2082:19: warning: conversion from 'int' to 'uint16_t' {aka 'short unsigned int'} may change value [-Wconversion] head->nb_segs += tail->nb_segs; ^~~~ Also uint16_t uint16_t nb_segs; /**< Number of segments. */ Fixes: 08b563ffb19d ("mbuf: replace data pointer by an offset") Fixes: 1a60a0daa6e4 ("mbuf: fix segments number type increase") Signed-off-by: Andy Green Acked-by: Bruce Richardson --- lib/librte_mbuf/rte_mbuf.h | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h index 38299992e..f247e43ca 100644 --- a/lib/librte_mbuf/rte_mbuf.h +++ b/lib/librte_mbuf/rte_mbuf.h @@ -1686,7 +1686,10 @@ static inline char *rte_pktmbuf_prepend(struct rte_mbuf *m, if (unlikely(len > rte_pktmbuf_headroom(m))) return NULL; - m->data_off -= len; + /* NB: elaborating the subtraction like this instead of using + * -= allows us to ensure the result type is uint16_t + * avoiding compiler warnings on gcc 8.1 at least */ + m->data_off = (uint16_t)(m->data_off - len); m->data_len = (uint16_t)(m->data_len + len); m->pkt_len = (m->pkt_len + len); @@ -1746,8 +1749,11 @@ static inline char *rte_pktmbuf_adj(struct rte_mbuf *m, uint16_t len) if (unlikely(len > m->data_len)) return NULL; + /* NB: elaborating the addition like this instead of using + * += allows us to ensure the result type is uint16_t + * avoiding compiler warnings on gcc 8.1 at least */ m->data_len = (uint16_t)(m->data_len - len); - m->data_off += len; + m->data_off = (uint16_t)(m->data_off + len); m->pkt_len = (m->pkt_len - len); return (char *)m->buf_addr + m->data_off; } @@ -1859,8 +1865,11 @@ static inline int rte_pktmbuf_chain(struct rte_mbuf *head, struct rte_mbuf *tail cur_tail = rte_pktmbuf_lastseg(head); cur_tail->next = tail; - /* accumulate number of segments and total length. */ - head->nb_segs += tail->nb_segs; + /* accumulate number of segments and total length. + * NB: elaborating the addition like this instead of using + * -= allows us to ensure the result type is uint16_t + * avoiding compiler warnings on gcc 8.1 at least */ + head->nb_segs = (uint16_t)(head->nb_segs + tail->nb_segs); head->pkt_len += tail->pkt_len; /* pkt_len is only set in the head */ -- 2.14.2