From patchwork Fri Jul 14 17:07:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Monjalon X-Patchwork-Id: 26913 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 8020A2C39; Fri, 14 Jul 2017 19:07:44 +0200 (CEST) Received: from out1-smtp.messagingengine.com (out1-smtp.messagingengine.com [66.111.4.25]) by dpdk.org (Postfix) with ESMTP id F21D12C2B for ; Fri, 14 Jul 2017 19:07:42 +0200 (CEST) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 3416920A83; Fri, 14 Jul 2017 13:07:42 -0400 (EDT) Received: from frontend2 ([10.202.2.161]) by compute1.internal (MEProxy); Fri, 14 Jul 2017 13:07:42 -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=NCb RNUjoTyAW6nq3lTlYH9GTNVCfMYRDvZAAxcIPb0k=; b=ovH1Wq3p0U2KFPYF3tq plWc2rHgtILxUwXS7MfdA4TltD+ak1qD+lyZy6Av+5ZWbmrvGBaxIu0LsdNoeHvg Juza71l2Wo9Bp+xmXb3FlulnvuNygRNZ9bVEFGoGcdE2KsjgtbBINwzm75eShq4K 2Y198QdGxnqTT9SXu8tWVrSk= 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=NCbRNUjoTyAW6nq3lTlYH9GTNVCfMYRDvZAAxcIPb 0k=; b=skr0gdE9AkH0BrgvNqkx3eYsXAFDDGqvujzXsS0TE5KWoqFp7v0TOocxc sLrKPjPJHC5iCaelcrh7XHxVLnAtFgHXAO5DEozIdru+nBeanNyCAX2O/EJc6P+3 5sqY6AHByW4+TZOwz+hK/9sdEZP3QJhD2U0OZYjJeJPapE+Oj4Vpkk792cwGUtvS fW5YBEPN/tABcSbUj4yWGZ1wDo5bffXDV+etWwP/KSo/XT7EWAzravQV4diUGO0w Hj1CEy+8StxNaUowwP3uC8787A3HQm6tGiyqGcRlM9lWH4G9hvweBjWEvdikV1At 73G5jsptQGBPB1iQ8qUMK5TML+Ibw== X-ME-Sender: X-Sasl-enc: nQr10UheqaStz6O8Ltrcc+1/g7KKWt1Hf1MhOArb2utE 1500052061 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 476D424288; Fri, 14 Jul 2017 13:07:41 -0400 (EDT) From: Thomas Monjalon To: stephen@networkplumber.org Cc: dev@dpdk.org, keith.wiles@intel.com Date: Fri, 14 Jul 2017 19:07:07 +0200 Message-Id: <20170714170707.22464-1-thomas@monjalon.net> X-Mailer: git-send-email 2.13.2 In-Reply-To: <20170711185546.26138-2-stephen@networkplumber.org> References: <20170711185546.26138-2-stephen@networkplumber.org> Subject: [dpdk-dev] [PATCH] 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 --- devtools/check-dup-includes.sh | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 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..ba9871255 --- /dev/null +++ b/devtools/check-dup-includes.sh @@ -0,0 +1,35 @@ +#! /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 the git repository for duplicated includes. + +cd $(dirname $(readlink -m $0))/.. + +# 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