[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] xen: Give compile.h header guards


  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: Nicola Vetrini <nicola.vetrini@xxxxxxxxxxx>
  • Date: Mon, 19 May 2025 21:20:58 +0200
  • Arc-authentication-results: i=1; bugseng.com; arc=none smtp.remote-ip=162.55.131.47
  • Arc-message-signature: i=1; d=bugseng.com; s=openarc; a=rsa-sha256; c=relaxed/relaxed; t=1747682458; h=DKIM-Signature:MIME-Version:Date:From:To:Cc:Subject:In-Reply-To: References:Message-ID:X-Sender:Organization:Content-Type: Content-Transfer-Encoding; bh=zxRF2dssG7vSmsDLWc8ihjORk55Chb9jxYYjVkZFTYc=; b=d40S1y421z+dxdoW7irVCO7pPP2JXCzT8ZwSNJjq9FVjejh5C/pN5+wLaWqxozaahCnf z2AdOUhonZ+BA4c92tWz9OE7ijsnssV4+n3gy2ofpgvPHhSh0VEo6bWc+/sz19bUdF3pc FGQqi0JQqLQ9eBd2Q9fKp9ENQvpqj32qRcJ6MSPe1o0Abqk0BsFG2VdvBJmXy2il0LNtx T7qgAZn5QEh1wqjwRU8nEpu5tpyyZq8z3JdlySXOGx6M13daJ+G1sFbHF7yoYpO74V0UE xiLT9XQu9xbJNvny5r0hFB2Yi0A8zH2/BFeKKYWLT77LXawOEW8J1Raw41xxoTlfa9+FZ uDnqBSJQfBpNnJsxWf+NTCYsFCAFVOYC8MRR/RwUFiY5buHrWnr1fjiU3DunKENooQJsk ASd3tc+OWLmYDknEX+FiwbEcK9ysFlHrLuvdFGG5F4ndPDp+VYyvTZqOVgZpgPV74yh2r YbxrPIMF7hCV4ZxRoEAlrGHlc4ojcINF1bs1Jbid/DMtGvgM1PAryyrBluiFa2DGoxwNr TaEFJ0qKTss2GDBTch05+J7lNBEOAg9YlZr2WBf5Alp4/tFbYJ1vGCs7crMY5d0y4mUzG 6+o3+aiL3AaQVXNHo8bmCpXWDLHClD1S7LGi1t7CNK4ZZOgUkF1CGNnDH//E3js=
  • Arc-seal: i=1; d=bugseng.com; s=openarc; a=rsa-sha256; cv=none; t=1747682458; b=heaalXsJ9UfQQr5H/jbcKatMFe6jTX/cHGBLteC4EvW51Eim3b/E0UhExc7BnV94idiQ xYxRiOtEX3c6Pf02P/dQ24W3I/KmxZlGRorIOR5Su0XMVDZJSVEQuvwQyvLNdW2arc9qv WDcwxFP7d+RKK4GhlHRNxR0EQ+4/PgwPJWObAb3hB58IvkX7RtfXp89yPvkXWeYrtL5Qb 6mJqRwBkA54YsSb2iwFjQREJJHKE8wnNCyLT4BsXEZsQkjLGNucOF/IAwmqU4hWNPvAn8 IhXLk909BJiGFkS9mhDfPty+psDXFaBa1jxDRH0aqd67tPyTllSshfQj5DFg8SlTiPAu5 K82+Gh0kNpfvd6I9Pm9yVFRPu93QXGMsabam8BUgjTOkgAjTMK3/PRa3J40b6inZdsGyS dNvJjRNhr6sLrj8+rTZThutTYmrYYHiipCyOastFAf5EYNvaW8dEmM2Ydiecxh11OWWNh 2U3A4g4PZggiUorJyGSzwAjWS+b7jT/vfjk6WLsM8/LecEOn0PiqH6K2l2hLILOXTH3Cq utdboPds4kmKLtnsKT2ghl5RGAsxMQN7cePlI5YCPSMi13mDc7C3UncTnwtwtsLxQbeKi KwsRXHY2B205N5f2qZmAyAhEO42O6CYPsw+5TeEAJlduUDe+R13OYvN2rE/1yhE=
  • Authentication-results: bugseng.com; arc=none smtp.remote-ip=162.55.131.47
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, Julien Grall <julien@xxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Mon, 19 May 2025 19:21:08 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 2025-05-19 21:10, Jan Beulich wrote:
On 19.05.2025 15:52, Andrew Cooper wrote:
Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>

Is this to please Misra in some way?


Directive 4.10: "Precautions shall be taken in order to prevent the contents of a header file being included more than once". One approach is to special-case this file, but Andrew suggested this approach which addresses the issue directly.

--- a/xen/include/xen/compile.h.in
+++ b/xen/include/xen/compile.h.in
@@ -1,3 +1,6 @@
+#ifndef XEN_COMPILE_H
+#define XEN_COMPILE_H
+
 #define XEN_COMPILE_DATE       "@@date@@"
 #define XEN_COMPILE_TIME       "@@time@@"
 #define XEN_COMPILE_BY         "@@whoami@@"
--- a/xen/tools/process-banner.sed
+++ b/xen/tools/process-banner.sed
@@ -12,3 +12,8 @@ s_(.*)_"\1\\n"_

 # Trailing \ on all but the final line.
 $!s_$_ \\_
+
+# Append closing header guard
+$a\
+\
+#endif /* XEN_COMPILE_H */

This split of #ifndef and #endif is ugly. Can't we switch to something
more conventional, like

#define XEN_BANNER              "@@banner@@"

with the first sed invocation then replacing this by the result of
a nested sed invocation using process-banner.sed (which of course would
need adjusting some)? (Maybe the double quotes would need omitting here,
for process-banner.sed to uniformly apply them.)

Jan

--
Nicola Vetrini, B.Sc.
Software Engineer
BUGSENG (https://bugseng.com)
LinkedIn: https://www.linkedin.com/in/nicola-vetrini-a42471253



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.