From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id E1CA0A0548; Tue, 7 Jun 2022 19:18:37 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E3DD842B82; Tue, 7 Jun 2022 19:18:01 +0200 (CEST) Received: from mail-pl1-f175.google.com (mail-pl1-f175.google.com [209.85.214.175]) by mails.dpdk.org (Postfix) with ESMTP id 0F8BE42B7B for ; Tue, 7 Jun 2022 19:18:00 +0200 (CEST) Received: by mail-pl1-f175.google.com with SMTP id o6so10280004plg.2 for ; Tue, 07 Jun 2022 10:17:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=obAcoptY+bJtw5ZiypXNxScwmPVzIlCC+4VV1kSt9vw=; b=k3PirejZgDaF8Ecd1ZQwDZe4RFAWq6i0wBBmSxlhrU2euL/34qZB8Qskq5LNhTYBO6 Ma/KAu6sva4Cg9E+s9v3y9L7aQDl1yfAp2lu9dLyT5HQphMSDWvjkqdWY0AGTv22Cn7N vpOrVhxqM46JfsbD1s8oKCUh1F181JpKztlDdF09mwZdqbZ2ATWQ0lUYX94/YtrJ4Sa3 gKyjYhPeZFoXa/p5aCaMflISvXEFXjN5vG+TmSsTFL7ei2pK1Tj5YV46Gt/HQwe83weI myZip0KUxn4+7h/TGYi3uyGaF8Ez87cSkHwqwUxDtnW+pV1skHPcyJpaPJdJzLHwGBUx B3SQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=obAcoptY+bJtw5ZiypXNxScwmPVzIlCC+4VV1kSt9vw=; b=K+ya9t/W9GYJ/QNcJV6RTrfoa2WXg1xumfGWC9O67XurgXMoYCsycB6+Vq99OQQlUo LG1kqPrrgZvVfHdgDj1QhknGWtt11RPeTNKRrn53nCFX18Bb07BEraqKTy4V/NMwysne umVgRcvLffsczs6MqAqU9tX03g47um6lqGcOz3x5MpAQEw9EcceAZ3B4ezcuq+ZHu4AP JagFitHCV611N7LjE0FS8fCEx6cTgE6TtVryqvLJu41EAZqcrnVuQSEwQDfPGOBk1ro1 ENXu4KKJb5hHXKgOJbMxdHv4BykY7ot2EOONVZwPFjVIk2JYVM+7nFVQpHgPIgfxkHC7 ToMw== X-Gm-Message-State: AOAM533gQctH+w7q0G8J8s42HoUiOM8ONq6Yxl1NL0Tinzt0PGMDbB5l hxs06xhd4+R3P9B2dB80AcBb054rNRB/Ig== X-Google-Smtp-Source: ABdhPJwjDaRXSWeQnKIKyXmUvTOtjfCNy4iNIGfNlC/Fjm0Ql2DTvHG7HICu5ioZ18x5bwJp+uwkyw== X-Received: by 2002:a17:902:c94b:b0:166:4f65:cffb with SMTP id i11-20020a170902c94b00b001664f65cffbmr25123516pla.103.1654622278834; Tue, 07 Jun 2022 10:17:58 -0700 (PDT) Received: from hermes.local (204-195-112-199.wavecable.com. [204.195.112.199]) by smtp.gmail.com with ESMTPSA id x2-20020a627c02000000b005087c23ad8dsm13185281pfc.0.2022.06.07.10.17.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 10:17:58 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Konstantin Ananyev Subject: [RFC 8/8] ip_frag: fix gcc-12 warnings Date: Tue, 7 Jun 2022 10:17:46 -0700 Message-Id: <20220607171746.461772-9-stephen@networkplumber.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220607171746.461772-1-stephen@networkplumber.org> References: <20220607171746.461772-1-stephen@networkplumber.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org The function rte_memcpy can derference past source buffer which will cause array out of bounds warnings. But there is no good reason to use rte_memcpy instead of memcpy in this code. Memcpy is just as fast for these small inputs, and compiler will optimize. Signed-off-by: Stephen Hemminger --- lib/ip_frag/rte_ipv4_fragmentation.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/ip_frag/rte_ipv4_fragmentation.c b/lib/ip_frag/rte_ipv4_fragmentation.c index a19f6fda6408..27a8ad224dec 100644 --- a/lib/ip_frag/rte_ipv4_fragmentation.c +++ b/lib/ip_frag/rte_ipv4_fragmentation.c @@ -5,7 +5,6 @@ #include #include -#include #include #include "ip_frag_common.h" @@ -26,7 +25,7 @@ static inline void __fill_ipv4hdr_frag(struct rte_ipv4_hdr *dst, const struct rte_ipv4_hdr *src, uint16_t header_len, uint16_t len, uint16_t fofs, uint16_t dofs, uint32_t mf) { - rte_memcpy(dst, src, header_len); + memcpy(dst, src, header_len); fofs = (uint16_t)(fofs + (dofs >> RTE_IPV4_HDR_FO_SHIFT)); fofs = (uint16_t)(fofs | mf << RTE_IPV4_HDR_MF_SHIFT); dst->fragment_offset = rte_cpu_to_be_16(fofs); @@ -48,7 +47,7 @@ static inline uint16_t __create_ipopt_frag_hdr(uint8_t *iph, struct rte_ipv4_hdr *iph_opt = (struct rte_ipv4_hdr *)ipopt_frag_hdr; ipopt_len = 0; - rte_memcpy(ipopt_frag_hdr, iph, sizeof(struct rte_ipv4_hdr)); + memcpy(ipopt_frag_hdr, iph, sizeof(struct rte_ipv4_hdr)); ipopt_frag_hdr += sizeof(struct rte_ipv4_hdr); uint8_t *p_opt = iph + sizeof(struct rte_ipv4_hdr); @@ -65,7 +64,7 @@ static inline uint16_t __create_ipopt_frag_hdr(uint8_t *iph, break; if (RTE_IPV4_HDR_OPT_COPIED(*p_opt)) { - rte_memcpy(ipopt_frag_hdr + ipopt_len, + memcpy(ipopt_frag_hdr + ipopt_len, p_opt, p_opt[1]); ipopt_len += p_opt[1]; } -- 2.35.1