From nobody Wed Feb 11 05:17:56 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1613136354; cv=none; d=zohomail.com; s=zohoarc; b=eB/x0c1gQn728zEblhKq8JqBFOjQV+4ZNaMJ2el/TVkL9tLUfmGC2bkHluUuEyY0pT3KDd1taoT6+EIB8dI9aUcyEQIRAJQY20HgApnyI9VQHuCTXO893vB7AAEUkcmC1kRpbp8N5qJVE4+/3NtbwyGFvgYwlbF5Pea1ksWNw5I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1613136354; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=HTraDd7OsdfeT5pdXBXV83l2Iq2KOtHyPxW0VgP/v2w=; b=mcSZ2GLqIpuFfBxAXGeOHF4DZbcTm3qa6MFdGLH1Y40X/XUS4Dz2W83ZudsAMrOXf3isiweFM1fnqHODyDXq4+uI7vtrLm4smafWfyn9TRvPxjoiPHHysmDjDrGVEmRhhWffZ+0Fd/ZRsnG5P7t0mCjhQxi4vxVed9XDgXcw+BA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1613136354163498.33449678995873; Fri, 12 Feb 2021 05:25:54 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-222-uYguaLQ7P3CiRPKGN6Lg3A-1; Fri, 12 Feb 2021 08:25:50 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 59E49107ACE6; Fri, 12 Feb 2021 13:25:45 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 19A311A262; Fri, 12 Feb 2021 13:25:45 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id A3CFE18095CC; Fri, 12 Feb 2021 13:25:42 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 11CDPdTv008591 for ; Fri, 12 Feb 2021 08:25:39 -0500 Received: by smtp.corp.redhat.com (Postfix) id A20786E51B; Fri, 12 Feb 2021 13:25:39 +0000 (UTC) Received: from work.redhat.com (ovpn-112-223.ams2.redhat.com [10.36.112.223]) by smtp.corp.redhat.com (Postfix) with ESMTP id E86F56E405; Fri, 12 Feb 2021 13:25:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1613136353; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=HTraDd7OsdfeT5pdXBXV83l2Iq2KOtHyPxW0VgP/v2w=; b=HfnFi+KfiVEzHqF4ZpUTviQcrAIlJ5avrMoGZ3S8iYWlCa8p5qO4Rgzt7XqKJFSKExBLzp bBrcOB+jjgkzrmDIgZ6pQ65cTl7f9PcFfA7lD1FIltfU+ykAqv6rWnXC3pYHBT7FArf+qW cRywLDTTiSAYEz5rNHKIU/puFz5eLAw= X-MC-Unique: uYguaLQ7P3CiRPKGN6Lg3A-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH 01/10] clang-tidy: Add a simple runner Date: Fri, 12 Feb 2021 14:25:25 +0100 Message-Id: <20210212132534.29066-2-twiederh@redhat.com> In-Reply-To: <20210212132534.29066-1-twiederh@redhat.com> References: <20210212132534.29066-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Cc: Tim Wiederhake X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Run clang-tidy with default configuration on all files listed in the compilation database. Note that the generated files in the build directory have to be built first. The simplest way to achieve this is to build libVirt first. Example: $ meson build && ninja -C build $ ./scripts/run-clang-tidy.py -p build Signed-off-by: Tim Wiederhake --- scripts/run-clang-tidy.py | 68 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100755 scripts/run-clang-tidy.py diff --git a/scripts/run-clang-tidy.py b/scripts/run-clang-tidy.py new file mode 100755 index 0000000000..10c8b80fe0 --- /dev/null +++ b/scripts/run-clang-tidy.py @@ -0,0 +1,68 @@ +#!/usr/bin/env python3 + +import argparse +import json +import os +import subprocess +import sys + + +def parse_args(): + parser =3D argparse.ArgumentParser(description=3D"caching clang-tidy r= unner") + parser.add_argument( + "-p", + dest=3D"build_dir", + default=3D".", + help=3D"Path to build directory") + + return parser.parse_args() + + +def run_clang_tidy(item): + cmd =3D ( + "clang-tidy", + "--warnings-as-errors=3D*", + "-p", + item["directory"], + item["file"]) + result =3D subprocess.run( + cmd, + stdout=3Dsubprocess.PIPE, + stderr=3Dsubprocess.PIPE, + universal_newlines=3DTrue) + return { + "returncode": result.returncode, + "stdout": result.stdout.strip(), + "stderr": result.stderr.strip(), + } + + +def worker(): + for item in items: + os.chdir(item["directory"]) + + print(item["file"]) + + result =3D run_clang_tidy(item) + + if result["returncode"] !=3D 0: + findings.append(item["file"]) + if result["stdout"]: + print(result["stdout"]) + if result["stderr"]: + print(result["stderr"]) + + +args =3D parse_args() +findings =3D list() + +with open(os.path.join(args.build_dir, "compile_commands.json")) as f: + items =3D json.load(f) + +worker() + +if findings: + print("Findings in %s file(s):" % len(findings)) + for finding in findings: + print(" %s" % finding) + sys.exit(1) --=20 2.26.2