From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id CE1E942C9A; Tue, 13 Jun 2023 01:55:21 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 54D8540C35; Tue, 13 Jun 2023 01:55:21 +0200 (CEST) Received: from mail-pf1-f178.google.com (mail-pf1-f178.google.com [209.85.210.178]) by mails.dpdk.org (Postfix) with ESMTP id 74DDF40698 for ; Tue, 13 Jun 2023 01:55:20 +0200 (CEST) Received: by mail-pf1-f178.google.com with SMTP id d2e1a72fcca58-652d76be8c2so5390281b3a.3 for ; Mon, 12 Jun 2023 16:55:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20221208.gappssmtp.com; s=20221208; t=1686614119; x=1689206119; 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=N1YeTuK4oTRgpAEkwyX9NtQvwi1DxaGkTuXylZC81oM=; b=Mw9OLIigFx71rD+V2de9FQBEkJRSA3kfBWPFmkvTO1cwmKNxLF5hkKFVcrK+qMUiLg zVNH7u4YLMAI/rlZMDv628S9wsx2uYy9fjbKQxUzKQrWUY1O1fC1TF5fIBuXD8ZoKsiK q2fcw44mfyvmaVrqfdP5cSImg9P8mGfMErlVk1lpxCqU3vqCcZSzpaXOuxeTXDbqmycd Yo4zb843oyI9nq2IMDhq5W81BlkP58/meaE/oHfqrMpqUWsgW93C7c9YYYSvCbnec9PL wyjpB5bqRzZi+a5ZIvTFn7MVG7lVGDtO0dd4O+wx/e8TH/PRy029XrNFcwc/1ReMtXO2 a50Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686614119; x=1689206119; 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=N1YeTuK4oTRgpAEkwyX9NtQvwi1DxaGkTuXylZC81oM=; b=Of7Ncczo5IH3hZZvrGlAZbUc714rYO/E9q0nbuG3GEb1diUj/9v3Q799vbeDFuToN1 A/NKumrMzVYT30IVtm7osYkZI0XnWLoy3+Td5O81VCOu2d0PW5vgM89e+ucalz2WGr2T VJnJt0LGy7e6RtDRtC/M+XuZ/3wm8dVnhn0Z4C8GTuy0jJoP1t8s8bWGAoZbP7FmgK+v 3R7Dwwk5eV7ZGqqkvLZmIiKxCnzkbueV9A4G3LdJnOQLD/I92pTPW4oqpFQ/NcLwqmj4 Q6mYmf3vRggL8cdQ70d7gF7+djd4TiaHvQOdNveV7trSdIEHkfaG1Lp/m2Dk12E4V3aH A3Ow== X-Gm-Message-State: AC+VfDzZbmw7HDcGCfsjIkGjGMUPYtquHKUQdMtet6GbwIaOZBA2t2Uy UaZj1OzXXGijgUy4K77KLYhA2g== X-Google-Smtp-Source: ACHHUZ6Fnz0L5S3rjXxAn37pZKwK4W0S89H5M5lz2Re+PYKB/8VrUq1rmbI9IQ3+Dny+BCVfKa3F5g== X-Received: by 2002:a05:6a00:99b:b0:658:c1a9:becc with SMTP id u27-20020a056a00099b00b00658c1a9beccmr14632263pfg.12.1686614119367; Mon, 12 Jun 2023 16:55:19 -0700 (PDT) Received: from hermes.local (204-195-120-218.wavecable.com. [204.195.120.218]) by smtp.gmail.com with ESMTPSA id a14-20020a63e84e000000b0054a15146f53sm5919125pgk.13.2023.06.12.16.55.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Jun 2023 16:55:18 -0700 (PDT) From: Stephen Hemminger To: ferruh.yigit@amd.com Cc: dev@dpdk.org, Ferruh Yigit , Stephen Hemminger Subject: [PATCH] devtools: add cppcheck wrapper Date: Mon, 12 Jun 2023 16:55:16 -0700 Message-Id: <20230612235516.63546-1-stephen@networkplumber.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20210211172758.2977369-1-ferruh.yigit@intel.com> References: <20210211172758.2977369-1-ferruh.yigit@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 From: Ferruh Yigit Adding wrapper script for cppcheck code analysis tool. usage: cppcheck.sh [-h] [cppcheck options] [path] Example: $ ./devtools/cppcheck.sh -q lib/ethdev/ The tool is useful but gets confused by macros in parts of DPDK. It identified some bogus code in netvsc driver, and some possible issues in pcapng. Would also like to do another round of dead code squashing Revised and simplified from original version by Ferruh Yigit. Let the user redirect output as they want, and allow passing options such as -q (quiet) and -v (verbose). Signed-off-by: Stephen Hemminger --- devtools/cppcheck.sh | 59 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100755 devtools/cppcheck.sh diff --git a/devtools/cppcheck.sh b/devtools/cppcheck.sh new file mode 100755 index 000000000000..df885df61423 --- /dev/null +++ b/devtools/cppcheck.sh @@ -0,0 +1,59 @@ +#! /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 +RTE_CONFIG=./build/rte_build_config.h + +which $CPPCHECK_BIN > /dev/null 2> /dev/null +if [ $? -ne 0 ]; then + echo "$CPPCHECK_BIN is missing!" >&2 + exit 1 +fi + +if [ ! -r $RTE_CONFIG ]; then + echo "Build not configured missing $RTE_CONFIG" >&2 + exit 1 +fi + +print_usage () { + cat <<- END_OF_HELP + usage: $(basename $0) [-h] [cppcheck options] [file or path] + + Run Linux cppcheck tool with DPDK options. + + END_OF_HELP +} + +if [ "$1" = "-h" ]; then + print_usage + exit 1; +fi + +suppress_args=" + --suppress=invalidPrintfArgType_sint \ + --suppress=invalidPrintfArgType_uint \ + --suppress=duplicateAssignExpression \ + --suppress=nullPointerRedundantCheck \ + --suppress=identicalConditionAfterEarlyExit \ + --suppress=objectIndex \ + --suppress=unknownMacro \ + " + +includes=" + --include=$RTE_CONFIG \ + --includes-file=lib/eal/include \ + --includes-file=lib/eal/linux/include \ + " + +# all, warning, performance, portability, +# information, unusedFunction, missingInclude +additional_checks=warning + +${CPPCHECK_BIN} --language=c ${includes} \ + --enable=${additional_checks} \ + --force ${suppress_args} $@ -- 2.39.2