[PATCH 2/8] wireshark: Switch header files to #pragma once

Michal Privoznik via Devel posted 8 patches 2 weeks ago
[PATCH 2/8] wireshark: Switch header files to #pragma once
Posted by Michal Privoznik via Devel 2 weeks ago
From: Michal Privoznik <mprivozn@redhat.com>

The genxdrstub.pl script generates some header files. But they
use the old pattern to guard against multiple inclusion:

  #ifndef SOMETHING_H
  #define SOMETHING_H
  ...
  #endif

Change the script to generate just '#pragma once' used everywhere
else in our code.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
---
 tools/wireshark/util/genxdrstub.pl | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/tools/wireshark/util/genxdrstub.pl b/tools/wireshark/util/genxdrstub.pl
index 8cfda25a27..01b663a88c 100755
--- a/tools/wireshark/util/genxdrstub.pl
+++ b/tools/wireshark/util/genxdrstub.pl
@@ -563,11 +563,8 @@ sub add_header_file {
     local $self->{header_contents} = [];
     $self->print("/* *DO NOT MODIFY* this file directly.\n");
     $self->print(" * This file was generated by $0 from libvirt version $libvirt_version */\n");
-    my $ucname = uc $name;
-    $self->print("#ifndef _$ucname\_H_\n");
-    $self->print("#define _$ucname\_H_\n");
+    $self->print("#pragma once\n");
     $block->();
-    $self->print("#endif /* _$ucname\_H_ */");
     push @{ $self->{headers} }, [ $name, delete $self->{header_contents} ];
 }
 
-- 
2.49.1
Re: [PATCH 2/8] wireshark: Switch header files to #pragma once
Posted by Peter Krempa via Devel 2 weeks ago
On Tue, Oct 14, 2025 at 08:31:41 +0200, Michal Privoznik via Devel wrote:
> From: Michal Privoznik <mprivozn@redhat.com>
> 
> The genxdrstub.pl script generates some header files. But they
> use the old pattern to guard against multiple inclusion:
> 
>   #ifndef SOMETHING_H
>   #define SOMETHING_H
>   ...
>   #endif
> 
> Change the script to generate just '#pragma once' used everywhere
> else in our code.
> 
> Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
> ---
>  tools/wireshark/util/genxdrstub.pl | 5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)

Reviewed-by: Peter Krempa <pkrempa@redhat.com>