From patchwork Thu Feb 11 17:27:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ferruh Yigit X-Patchwork-Id: 87876 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 4E1ABA054D; Thu, 11 Feb 2021 18:28:08 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C902B227F63; Thu, 11 Feb 2021 18:28:07 +0100 (CET) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by mails.dpdk.org (Postfix) with ESMTP id 68EB440147 for ; Thu, 11 Feb 2021 18:28:06 +0100 (CET) IronPort-SDR: LVsOdUSIOan+T9aI38bHsxPJHfns4g8hHkqKsdcEqx6CO2FEWbcBBYmB3kveVs+HFdZgJGuIPu I1NPiMzTT/7w== X-IronPort-AV: E=McAfee;i="6000,8403,9892"; a="161425340" X-IronPort-AV: E=Sophos;i="5.81,170,1610438400"; d="scan'208";a="161425340" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Feb 2021 09:28:01 -0800 IronPort-SDR: wn22DUYbm7/MjVygqkDxrn00pdpCv3/soGzTlvmwLAxTnhfVvGye/AcSsTExXuaqcAK8lTEvCS WNtJxorL1I1g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.81,170,1610438400"; d="scan'208";a="380810651" Received: from silpixa00399752.ir.intel.com (HELO silpixa00399752.ger.corp.intel.com) ([10.237.222.27]) by fmsmga008.fm.intel.com with ESMTP; 11 Feb 2021 09:28:00 -0800 From: Ferruh Yigit To: dev@dpdk.org Cc: Ferruh Yigit Date: Thu, 11 Feb 2021 17:27:58 +0000 Message-Id: <20210211172758.2977369-1-ferruh.yigit@intel.com> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH] devtools: add cppcheck wrapper 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 Sender: "dev" Adding wrapper script for cppcheck code analysis tool. usage: cppcheck.sh [-h] [path] Without any argument current folder scanned with all sub folders, if 'path' argument provided, that 'path' is scanned with all its subfolders, like: "./devtools/cppcheck.sh lib/librte_ethdev/" The output log is saved to 'cppcheck_error.txt' in current folder. Signed-off-by: Ferruh Yigit --- devtools/cppcheck.sh | 67 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100755 devtools/cppcheck.sh diff --git a/devtools/cppcheck.sh b/devtools/cppcheck.sh new file mode 100755 index 000000000000..935eb5d9d625 --- /dev/null +++ b/devtools/cppcheck.sh @@ -0,0 +1,67 @@ +#! /bin/sh +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2021 Intel Corporation + +# wrapper script for cppcheck code analysis tool +# Args: +# $1: path to scan (optional) + +CPPCHECK_BIN=cppcheck +out=cppcheck_error.txt + +which ${CPPCHECK_BIN} > /dev/null 2> /dev/null +if [ $? -ne 0 ]; then + echo "${CPPCHECK_BIN} is missing!" + exit 1 +fi + +print_usage () { + cat <<- END_OF_HELP + usage: $(basename $0) [-h] [path] + + Wrapper on checkpatch tool. Output goes to ${out} file. + + Without parameter current folder with all subfolders scanned. It is possible + to provide a sub-folder to recude the scan to that folder. + END_OF_HELP +} + +if [ "$1" = "-h" ]; then + print_usage + exit 1; +fi + +dir=${1:-$(dirname $(readlink -f $0))/..} +if [ ! -e ${dir} ]; then + echo "\"${dir}\" is not valid folder/file to check" + exit 1 +fi + + +suppress_args=" + --suppress=invalidPrintfArgType_sint \ + --suppress=invalidPrintfArgType_uint \ + --suppress=duplicateAssignExpression \ + --suppress=nullPointerRedundantCheck \ + --suppress=identicalConditionAfterEarlyExit \ + --suppress=objectIndex + " + +# all, warning, performance, portability, +# information, unusedFunction, missingInclude +additional_checks=warning + +${CPPCHECK_BIN} \ + -j64 \ + --language=c \ + --enable=${additional_checks} \ + --force \ + ${suppress_args} \ + ${dir} \ + 2> ${out} + +if [ $? -eq 0 ]; then + echo -e "\nOutput saved to ${out}" +else + exit $? +fi