From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id C5E0CA0679 for ; Wed, 3 Apr 2019 16:45:43 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 6F4421B46F; Wed, 3 Apr 2019 16:45:28 +0200 (CEST) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by dpdk.org (Postfix) with ESMTP id 86ADB1B46F for ; Wed, 3 Apr 2019 16:45:27 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 Apr 2019 07:45:27 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,304,1549958400"; d="scan'208";a="312832737" Received: from silpixa00399126.ir.intel.com (HELO silpixa00399126.ger.corp.intel.com) ([10.237.222.236]) by orsmga005.jf.intel.com with ESMTP; 03 Apr 2019 07:45:26 -0700 From: Bruce Richardson To: dev@dpdk.org Cc: Bruce Richardson Date: Wed, 3 Apr 2019 15:45:03 +0100 Message-Id: <20190403144505.46234-4-bruce.richardson@intel.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190403144505.46234-1-bruce.richardson@intel.com> References: <20190403144505.46234-1-bruce.richardson@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH 3/5] devtools/cocci: create safer version of strlcpy script 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Content-Type: text/plain; charset="UTF-8" Message-ID: <20190403144503.A-Ctthox6fNf_zLSKFDnFh4IRHEb29QbH2cs03axPp8@z> The existing cocci script for coccinelle replaces all matching instances of snprintf() with strlcpy() without regards to header inclusion. To allow changes without build errors, we create a safer version of this script that only makes changes when the rte_string_fns.h header is already included. Signed-off-by: Bruce Richardson --- devtools/cocci/strlcpy-with-header.cocci | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 devtools/cocci/strlcpy-with-header.cocci diff --git a/devtools/cocci/strlcpy-with-header.cocci b/devtools/cocci/strlcpy-with-header.cocci new file mode 100644 index 000000000..046cdbdad --- /dev/null +++ b/devtools/cocci/strlcpy-with-header.cocci @@ -0,0 +1,12 @@ +@include@ +@@ + +#include + +@use_strlcpy depends on include@ +expression src, dst, size; +@@ +( +- snprintf(dst, size, "%s", src) ++ strlcpy(dst, src, size) +) -- 2.20.1