From patchwork Sat Jul 15 10:00:33 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Monjalon X-Patchwork-Id: 26944 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id 51C942882; Sat, 15 Jul 2017 12:00:42 +0200 (CEST) Received: from out1-smtp.messagingengine.com (out1-smtp.messagingengine.com [66.111.4.25]) by dpdk.org (Postfix) with ESMTP id E749B276C for ; Sat, 15 Jul 2017 12:00:40 +0200 (CEST) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 90694206F5; Sat, 15 Jul 2017 06:00:40 -0400 (EDT) Received: from frontend2 ([10.202.2.161]) by compute1.internal (MEProxy); Sat, 15 Jul 2017 06:00:40 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= cc:date:from:in-reply-to:message-id:references:subject:to :x-me-sender:x-me-sender:x-sasl-enc:x-sasl-enc; s=mesmtp; bh=bXI GRG8LIEXVYG8cZVWeugnU85mYRwfUb6JV626KtyA=; b=hT7+VV9I5JOT36C5DtL /jaT8FQn1L6U8DIZTWHjhlE5Q644d1qz56T7wVDmvlA/lyR6SedrJyeUy/a4MRDN yqR1eCNfCTfKlhG/WL/xjAL5shnoAShgBsBSDXjPjfYrI1WUbW368TDXer9wDtPH D8jzqA3RNcMGkEvktiJJMFS4= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:in-reply-to:message-id :references:subject:to:x-me-sender:x-me-sender:x-sasl-enc :x-sasl-enc; s=fm1; bh=bXIGRG8LIEXVYG8cZVWeugnU85mYRwfUb6JV626Kt yA=; b=VEmjWclq/eP1vnvEnPquS6uhxmo3WzMdepx6/AgiV/6lk1d7A1kkoPi3x awHenHJwrtcaXKfF9seROT2s8MT7KfaZ4dDt8FcmoNh342tMFHHdRqfQVzEo/zv6 dc9wYACoLmkj03VzgdVIrCCJgaQEV4EWZbVWemmAlnDb2IjU8besX2E8m/eQIYJi BDk21eioHtzK+Hyn+AfdmF6a7ApbtPfDPaHCaWJu88zZ/Tu0TCWfws6j5cS4kgEK N2BTVTYS+cnRV0CtVHjDhSPJ2NLLzDo16cN8cBDgSb8wwiYbaZSWoCC+oaFzGKwg ALN/K/y+YQMdvHpTdrVGtaDLQNwsw== X-ME-Sender: X-Sasl-enc: qLU9xoN1tIHMMU1W3sjUTAcPn69mpB9ZWRj6EDOM0JML 1500112839 Received: from xps.monjalon.net (apoitiers-656-1-613-51.w109-214.abo.wanadoo.fr [109.214.42.51]) by mail.messagingengine.com (Postfix) with ESMTPA id 71BA82470F; Sat, 15 Jul 2017 06:00:39 -0400 (EDT) From: Thomas Monjalon To: stephen@networkplumber.org Cc: dev@dpdk.org, keith.wiles@intel.com Date: Sat, 15 Jul 2017 12:00:33 +0200 Message-Id: <20170715100033.19872-1-thomas@monjalon.net> X-Mailer: git-send-email 2.13.2 In-Reply-To: <20170714170707.22464-1-thomas@monjalon.net> References: <20170714170707.22464-1-thomas@monjalon.net> Subject: [dpdk-dev] [PATCH v2] devtools: add script to find duplicated includes 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" Based on Stephen's idea (originally implemented in a Perl script), this is a shell script to find duplicated includes in a file. It looks for all the .c and .h files of the git repository. It is fast enough because automatically well parallelized. Suggested-by: Stephen Hemminger Signed-off-by: Thomas Monjalon Tested-by: Keith Wiles --- v2: add optional parameter for directory as suggested by Keith --- devtools/check-dup-includes.sh | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100755 devtools/check-dup-includes.sh diff --git a/devtools/check-dup-includes.sh b/devtools/check-dup-includes.sh new file mode 100755 index 000000000..10365e4a1 --- /dev/null +++ b/devtools/check-dup-includes.sh @@ -0,0 +1,37 @@ +#! /bin/sh -e + +# Copyright 2017 Mellanox Technologies, Ltd. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +# Check C files in git repository for duplicated includes. +# Usage: devtools/check-dup-includes.sh [directory] + +dir=${1:-$(dirname $(readlink -m $0))/..} +cd $dir + +# speed up by ignoring Unicode details +export LC_ALL=C + +for file in $(git ls-files '*.[ch]') ; do + sed -rn 's,^[[:space:]]*#include[[:space:]]*[<"](.*)[>"].*,\1,p' $file | + sort | uniq -d | + sed "s,^,$file: duplicated include: ," +done