From nobody Sat Oct 25 13:08:11 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1521643952282863.2716881432842; Wed, 21 Mar 2018 07:52:32 -0700 (PDT) Received: from localhost ([::1]:55559 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eyf6N-0008DP-Bq for importer@patchew.org; Wed, 21 Mar 2018 10:52:31 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39309) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eyf1L-00040m-7W for qemu-devel@nongnu.org; Wed, 21 Mar 2018 10:47:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eyf1F-0005EH-K9 for qemu-devel@nongnu.org; Wed, 21 Mar 2018 10:47:19 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:46892 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eyf17-00058Q-S7; Wed, 21 Mar 2018 10:47:05 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7C8254023BB3; Wed, 21 Mar 2018 14:47:04 +0000 (UTC) Received: from redhat.com (ovpn-124-179.rdu2.redhat.com [10.10.124.179]) by smtp.corp.redhat.com (Postfix) with SMTP id E796A10B00A5; Wed, 21 Mar 2018 14:46:32 +0000 (UTC) Date: Wed, 21 Mar 2018 16:46:32 +0200 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org, Daniel =?utf-8?B?UC4gQmVycmFuZ8Op?= Message-ID: <1521642402-197739-1-git-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Disposition: inline X-Mutt-Fcc: =sent X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Wed, 21 Mar 2018 14:47:05 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Wed, 21 Mar 2018 14:47:05 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'mst@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH v2] qemu: replace "" with <> in headers X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Dmitry Fleytman , Pavel Dovgalyuk , Li Zhijian , David Hildenbrand , Jeff Cody , Stefan Hajnoczi , Keith Busch , Max Filippov , Hannes Reinecke , Gerd Hoffmann , Fam Zheng , Max Reitz , Josh Durgin , Stefano Stabellini , Alberto Garcia , zhanghailiang , Ben Warren , Stefan Berger , Yongbok Kim , Michael Roth , "Richard W.M. Jones" , Christian Borntraeger , =?utf-8?B?SGVydsOp?= Poussineau , =?utf-8?Q?Marc-Andr=C3=A9?= Lureau , Shannon Zhao , Marcel Apfelbaum , Liu Yuan , Richard Henderson , Jason Wang , Artyom Tarasenko , Thomas Huth , Alistair Francis , Jiri Pirko , Eduardo Habkost , Corey Minyard , Amit Shah , Stefan Weil , Xie Changlong , Riku Voipio , Peter Lieven , "Dr. David Alan Gilbert" , Yuval Shaia , Greg Kurz , Anthony Perard , Alex Williamson , qemu-arm@nongnu.org, Peter Chubb , Ronnie Sahlberg , Zhang Chen , xen-devel@lists.xenproject.org, John Snow , David Gibson , Kevin Wolf , kvm@vger.kernel.org, qemu-block@nongnu.org, Peter Crosthwaite , Hitoshi Mitake , Markus Armbruster , qemu-s390x@nongnu.org, Marcelo Tosatti , Laurent Vivier , Juan Quintela , Subbaraya Sundeep , Michael Walle , Igor Mammedov , qemu-ppc@nongnu.org, Wen Congyang , Cornelia Huck , Paolo Bonzini , Andreas =?utf-8?Q?F=C3=A4rber?= , Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Our current scheme is to use #include "" for internal headers, and #include <> for external ones. Unfortunately this is not based on compiler support: from C point of view, the "" form merely looks up headers in the current directory and then falls back on <> directories. Thus, for example, a system header trace.h - should it be present - will conflict with our local trace.h As another example of problems, a header by the same name in the source directory will always be picked up first - before any headers in the include directory. Let's change the scheme: make sure all headers that are not in the source directory are included through a path starting with qemu/ , thus: #include <> headers in the same directory as source are included with #include "" as per standard. This (untested) patch is just to start the discussion and does not change all of the codebase. If there's agreement, this will be run on all code to converting code to this scheme. Signed-off-by: Michael S. Tsirkin --- scripts/changeheaders.pl | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100755 scripts/changeheaders.pl diff --git a/scripts/changeheaders.pl b/scripts/changeheaders.pl new file mode 100755 index 0000000..22bd5b8 --- /dev/null +++ b/scripts/changeheaders.pl @@ -0,0 +1,20 @@ +#!/usr/bin/perl -pi + +if (m@^\s*#include\s+"([^"+]"@o) { + next; +} + +my $hdr =3D $1; +my $file =3D $ARGV; +$file =3D~ s@/[^/]+$@@g; +$file .=3D $hdr; + +if (-e $file) { + next; +} + +if (m@^\s*#include\s+"qemu/@o) { + s@^(\s*#include\s+)"qemu/([^"]+)"(.*)$@$1$3@o) { +} else { + s@^(\s*#include\s+)"([^"]+)"(.*)$@$1$3@o) { +} --=20 MST