From patchwork Fri Mar 1 17:14:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 137691 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id BE94F43C12; Fri, 1 Mar 2024 18:17:19 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id AA55542FF1; Fri, 1 Mar 2024 18:17:19 +0100 (CET) Received: from mail-pl1-f178.google.com (mail-pl1-f178.google.com [209.85.214.178]) by mails.dpdk.org (Postfix) with ESMTP id 0657042FE9 for ; Fri, 1 Mar 2024 18:17:18 +0100 (CET) Received: by mail-pl1-f178.google.com with SMTP id d9443c01a7336-1dc9222b337so23651385ad.2 for ; Fri, 01 Mar 2024 09:17:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1709313437; x=1709918237; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=g6uhYXuFO0hkzj3eBHFdCdGhcudl4GtPWett1S7Oeck=; b=xBXw7S2XkOXjkOWhI/0x3lVQFRWSL4FlkrO6/oGOCSG9ysQ0RN2TgNnWv8mvU8Kbn0 9dcuDRVPn7NnEq6/xnKDbGBmKEsP2gNVwyZ8/LSWZ66qbdOs5GOkHZ8Py83P9nDAB53a ztieT9x0uA8OwHgBP7k/9sF+QixjuKp4AszMC1aRIETs2toHqOfmn3sB8aOa9UYqmMRS SX9BfsU9kLKIiZNF3IuwafIB0Esd5t2d2+M+ubH/cnZpDmO9EQnAvNcOlAhZyOHsPhEK 695f+NHki0OjfGyvCpMh8k4EEVqpkFFlUMSGr4QY2vVDHTCxKjiZXtoffILIsHm0qpnZ VClA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709313437; x=1709918237; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=g6uhYXuFO0hkzj3eBHFdCdGhcudl4GtPWett1S7Oeck=; b=WrVujpnzlSy6JoUdXp9NZ7+8llMFubXec4yxbpZ3wjt0Ef+1pPZ/8oSJPDWUnzcbtz CxUboOJNNAYmtlK0+sAwMMAGFwg/3uuBVappC7oe6ZyN7HwY9DUrk4as0oa6b7xPMLvQ F3ybChNtLXMj0g1k1YHRnggrJlWB7DPBMSp8taLEtwIm8fxBF+FK8h7OaS8mYjWGyhns ym84quPalb/CTVMm2C+kg1CGhUspYmVNfs8pwsUW8eI0NRLuTtz7UQTjMfGNpGaYWdS4 G1BHMAFMAPllK9Jhs/2dWaHlzhpzSBJewPSrHwqTHbtRiGeesMbBGaQ8KEaRR6SRDQ03 z+BQ== X-Gm-Message-State: AOJu0YxMeSZs5ue7V1txMnWAWHsUsghKx03p8BfnBG0tw4wU9c7saodc liK/Lt+3ZfOdyOkwNHBCbJg+mWHF0HDxVKl6Evk5MSucyBWeN//tK4HaNCXZYHPaIshYvYJMRp7 v9FiWUw== X-Google-Smtp-Source: AGHT+IFGfq40YCM+AIUzkRAQWFVeLPkBU7itYUMw/5ANJ8JPQi66fRqSKngNJ8jD66fsqHeuth3k+g== X-Received: by 2002:a17:902:7c0f:b0:1dc:69ab:7dc0 with SMTP id x15-20020a1709027c0f00b001dc69ab7dc0mr1886285pll.27.1709313437164; Fri, 01 Mar 2024 09:17:17 -0800 (PST) Received: from hermes.local (204-195-123-141.wavecable.com. [204.195.123.141]) by smtp.gmail.com with ESMTPSA id j14-20020a170902da8e00b001dc8d6a9d40sm3695764plx.144.2024.03.01.09.17.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 09:17:16 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Subject: [PATCH v2 01/71] cocci/rte_memcpy: add script to eliminate fixed size rte_memcpy Date: Fri, 1 Mar 2024 09:14:57 -0800 Message-ID: <20240301171707.95242-2-stephen@networkplumber.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240301171707.95242-1-stephen@networkplumber.org> References: <20240229225936.483472-1-stephen@networkplumber.org> <20240301171707.95242-1-stephen@networkplumber.org> MIME-Version: 1.0 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 Rte_memcpy should not be used for the simple case of copying a fix size structure because it is slower and will hide problems from code analysis tools. Coverity, fortify and other analyzers special case memcpy(). Gcc (and Clang) are smart enough to inline copies which will be faster. Signed-off-by: Stephen Hemminger --- devtools/cocci/rte_memcpy.cocci | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 devtools/cocci/rte_memcpy.cocci diff --git a/devtools/cocci/rte_memcpy.cocci b/devtools/cocci/rte_memcpy.cocci new file mode 100644 index 000000000000..fa1038fc066d --- /dev/null +++ b/devtools/cocci/rte_memcpy.cocci @@ -0,0 +1,11 @@ +// +// rte_memcpy should not be used for simple fixed size structure +// because compiler's are smart enough to inline these. +// +@@ +expression src, dst; constant size; +@@ +( +- rte_memcpy(dst, src, size) ++ memcpy(dst, src, size) +)