From nobody Mon Apr 29 15:29:48 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 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=1560973781; cv=none; d=zoho.com; s=zohoarc; b=lethTd7MWvuAcwSm8zbSEgdVd8nRluw3Aav5boGOlo4L17/DepyzhrR5CaceJlqSEQ3aS+35rwupfFMLYf1wUxVCjsGSK0LzvdGg6MkojYkr8uJjtQxcF305y94zpQVYW5K8TzEOgERQH60rruoOGK0qmc0x/aCYIQkJLFDT7yo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560973781; h=Content-Type:Content-Transfer-Encoding:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To:ARC-Authentication-Results; bh=/gHElCcXEyMSLo+/SW2T+14iGqHjuFE9BgAsKZ0FVnY=; b=Mwt7TJ7RNk4DPHZqZG/hz4AcWGcaHGM3glMEFYVQduA2PYpUA5ZXf/s+sbYBENCk/dX4Es9QJE//qTwlzLu9p149pIXCTIsjIcXI3s4/BI5FSiBOrw47cSeO9lRZMOoV5BichU1+wNhJe1WdG0rQPnipYe6RbHfO9A0NaUeWRso= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1560973781531401.7067083782009; Wed, 19 Jun 2019 12:49:41 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1208B30C0DFF; Wed, 19 Jun 2019 19:49:10 +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 EAF876012D; Wed, 19 Jun 2019 19:48:58 +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 035A21806B18; Wed, 19 Jun 2019 19:48:43 +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 x5JJmft1023253 for ; Wed, 19 Jun 2019 15:48:41 -0400 Received: by smtp.corp.redhat.com (Postfix) id 512A7608CA; Wed, 19 Jun 2019 19:48:41 +0000 (UTC) Received: from aegolius.redhat.com (ovpn-117-198.phx2.redhat.com [10.3.117.198]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1EE31608A5 for ; Wed, 19 Jun 2019 19:48:38 +0000 (UTC) From: Jonathon Jongsma To: libvir-list@redhat.com Date: Wed, 19 Jun 2019 14:48:36 -0500 Message-Id: <20190619194836.29799-1-jjongsma@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2] syntax check: update header guard check 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: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Wed, 19 Jun 2019 19:49:34 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Internal headers should use #pragma once instead of the standard #ifndef guard. Public headers still require the existing header guard. Signed-off-by: Jonathon Jongsma Reviewed-by: J=C3=A1n Tomko --- Changes in v2: - fix error messages when no header guard is found (#ifndef for public hea= ders, #pragma for internal headers) - fix test for identifying public headers (omit initial '/') - fix code spacing build-aux/header-ifdef.pl | 41 +++++++++++++++++++++++++++++---------- 1 file changed, 31 insertions(+), 10 deletions(-) diff --git a/build-aux/header-ifdef.pl b/build-aux/header-ifdef.pl index 401f25fb81..dba3dbcbdc 100644 --- a/build-aux/header-ifdef.pl +++ b/build-aux/header-ifdef.pl @@ -6,18 +6,26 @@ # ...copyright header... # */ # -# #ifndef SYMBOL -# # define SYMBOL +# #pragma once # ....content.... -# #endif /* SYMBOL */ # -# For any file ending priv.h, before the #ifndef +#--- +# +# For any file ending priv.h, before the #pragma once # We will have a further section # # #ifndef SYMBOL_ALLOW # # error .... # #endif /* SYMBOL_ALLOW */ # +# +#--- +# +# For public headers (files in include/), use the standard header guard in= stead of #pragma once: +# #ifndef SYMBOL +# # define SYMBOL +# ....content.... +# #endif /* SYMBOL */ =20 use strict; use warnings; @@ -38,6 +46,7 @@ my $file =3D " "; my $ret =3D 0; my $ifdef =3D ""; my $ifdefpriv =3D ""; +my $publicheader =3D 0; =20 my $state =3D $STATE_EOF; my $mistake =3D 0; @@ -64,7 +73,11 @@ while (<>) { } elsif ($state =3D=3D $STATE_PRIV_BLANK) { &mistake("$file: missing blank line after priv header check"); } elsif ($state =3D=3D $STATE_GUARD_START) { - &mistake("$file: missing '#ifndef $ifdef'"); + if ($publicheader) { + &mistake("$file: missing '#ifndef $ifdef'"); + } else { + &mistake("$file: missing '#pragma once' header guard"); + } } elsif ($state =3D=3D $STATE_GUARD_DEFINE) { &mistake("$file: missing '# define $ifdef'"); } elsif ($state =3D=3D $STATE_GUARD_END) { @@ -83,6 +96,7 @@ while (<>) { $file =3D $ARGV; $state =3D $STATE_COPYRIGHT_COMMENT; $mistake =3D 0; + $publicheader =3D ($ARGV =3D~ /include\//); } =20 if ($mistake || @@ -133,12 +147,19 @@ while (<>) { } elsif ($state =3D=3D $STATE_GUARD_START) { if (/^$/) { &mistake("$file: too many blank lines after copyright header"); - } elsif(/#pragma once/) { - $state =3D $STATE_PRAGMA; - } elsif (/#ifndef $ifdef$/) { - $state =3D $STATE_GUARD_DEFINE; + } + if ($publicheader) { + if (/#ifndef $ifdef$/) { + $state =3D $STATE_GUARD_DEFINE; + } else { + &mistake("$file: missing '#ifndef $ifdef'"); + } } else { - &mistake("$file: missing '#ifndef $ifdef'"); + if (/#pragma once/) { + $state =3D $STATE_PRAGMA; + } else { + &mistake("$file: missing '#pragma once' header guard"); + } } } elsif ($state =3D=3D $STATE_GUARD_DEFINE) { if (/# define $ifdef$/) { --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list