From be84b189dcdaab2edcf304eee39d983e8b6715c7 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Mon, 26 Feb 2024 13:01:12 +0100 Subject: [PATCH] util, io, net, ...: use "#pragma once" --- src/io/BufferedOutputStream.hxx | 5 +---- src/io/Open.hxx | 5 +---- src/io/OutputStream.hxx | 5 +---- src/io/Reader.hxx | 5 +---- src/io/StdioOutputStream.hxx | 5 +---- src/io/UniqueFileDescriptor.hxx | 5 +---- src/lib/curl/Global.hxx | 5 +---- src/lib/curl/Slist.hxx | 5 +---- src/lib/curl/String.hxx | 5 +---- src/lib/dbus/Connection.hxx | 5 +---- src/lib/dbus/Iter.hxx | 5 +---- src/lib/dbus/Message.hxx | 5 +---- src/lib/dbus/PendingCall.hxx | 5 +---- src/lib/dbus/ScopeMatch.hxx | 5 +---- src/lib/dbus/Types.hxx | 5 +---- src/lib/zlib/Error.hxx | 5 +---- src/lib/zlib/GunzipReader.hxx | 5 +---- src/net/IPv4Address.hxx | 5 +---- src/net/IPv6Address.hxx | 5 +---- src/net/Resolver.hxx | 5 +---- src/util/AllocatedString.hxx | 5 +---- src/util/Cast.hxx | 5 +---- src/util/CharUtil.hxx | 5 +---- src/util/DeleteDisposer.hxx | 5 +---- src/util/DynamicFifoBuffer.hxx | 5 +---- src/util/Exception.hxx | 5 +---- src/util/PrintException.hxx | 5 +---- src/util/ScopeExit.hxx | 5 +---- src/util/ShallowCopy.hxx | 5 +---- src/util/StringAPI.hxx | 5 +---- src/util/StringBuffer.hxx | 5 +---- src/util/StringPointer.hxx | 5 +---- 32 files changed, 32 insertions(+), 128 deletions(-) diff --git a/src/io/BufferedOutputStream.hxx b/src/io/BufferedOutputStream.hxx index 68d0c0c4f..73a71c037 100644 --- a/src/io/BufferedOutputStream.hxx +++ b/src/io/BufferedOutputStream.hxx @@ -1,8 +1,7 @@ // SPDX-License-Identifier: BSD-2-Clause // author: Max Kellermann -#ifndef BUFFERED_OUTPUT_STREAM_HXX -#define BUFFERED_OUTPUT_STREAM_HXX +#pragma once #include "util/DynamicFifoBuffer.hxx" #include "util/SpanCast.hxx" @@ -130,5 +129,3 @@ WithBufferedOutputStream(OutputStream &os, F &&f) f(bos); bos.Flush(); } - -#endif diff --git a/src/io/Open.hxx b/src/io/Open.hxx index fee352ab3..2ff0501f8 100644 --- a/src/io/Open.hxx +++ b/src/io/Open.hxx @@ -1,8 +1,7 @@ // SPDX-License-Identifier: BSD-2-Clause // author: Max Kellermann -#ifndef OPEN_HXX -#define OPEN_HXX +#pragma once class FileDescriptor; class UniqueFileDescriptor; @@ -38,5 +37,3 @@ UniqueFileDescriptor OpenDirectory(FileDescriptor directory, const char *name, int flags=0); #endif - -#endif diff --git a/src/io/OutputStream.hxx b/src/io/OutputStream.hxx index 72e485f45..bb5e6826f 100644 --- a/src/io/OutputStream.hxx +++ b/src/io/OutputStream.hxx @@ -1,8 +1,7 @@ // SPDX-License-Identifier: BSD-2-Clause // author: Max Kellermann -#ifndef OUTPUT_STREAM_HXX -#define OUTPUT_STREAM_HXX +#pragma once #include #include @@ -17,5 +16,3 @@ public: */ virtual void Write(std::span src) = 0; }; - -#endif diff --git a/src/io/Reader.hxx b/src/io/Reader.hxx index 2602ce25f..73bce7bf1 100644 --- a/src/io/Reader.hxx +++ b/src/io/Reader.hxx @@ -1,8 +1,7 @@ // SPDX-License-Identifier: BSD-2-Clause // author: Max Kellermann -#ifndef READER_HXX -#define READER_HXX +#pragma once #include #include @@ -41,5 +40,3 @@ public: ReadFull(std::as_writable_bytes(std::span{&dest, 1})); } }; - -#endif diff --git a/src/io/StdioOutputStream.hxx b/src/io/StdioOutputStream.hxx index 55f4b7c23..7bf2fc85e 100644 --- a/src/io/StdioOutputStream.hxx +++ b/src/io/StdioOutputStream.hxx @@ -1,8 +1,7 @@ // SPDX-License-Identifier: BSD-2-Clause // author: Max Kellermann -#ifndef STDIO_OUTPUT_STREAM_HXX -#define STDIO_OUTPUT_STREAM_HXX +#pragma once #include "OutputStream.hxx" @@ -21,5 +20,3 @@ public: /* this class is debug-only and ignores errors */ } }; - -#endif diff --git a/src/io/UniqueFileDescriptor.hxx b/src/io/UniqueFileDescriptor.hxx index aaaab5610..1e2aec8b8 100644 --- a/src/io/UniqueFileDescriptor.hxx +++ b/src/io/UniqueFileDescriptor.hxx @@ -1,8 +1,7 @@ // SPDX-License-Identifier: BSD-2-Clause // author: Max Kellermann -#ifndef UNIQUE_FILE_DESCRIPTOR_HXX -#define UNIQUE_FILE_DESCRIPTOR_HXX +#pragma once #include "FileDescriptor.hxx" // IWYU pragma: export @@ -72,5 +71,3 @@ public: return IsDefined() && FileDescriptor::Close(); } }; - -#endif diff --git a/src/lib/curl/Global.hxx b/src/lib/curl/Global.hxx index 9b6e2c90f..6bca3338f 100644 --- a/src/lib/curl/Global.hxx +++ b/src/lib/curl/Global.hxx @@ -1,8 +1,7 @@ // SPDX-License-Identifier: BSD-2-Clause // author: Max Kellermann -#ifndef CURL_GLOBAL_HXX -#define CURL_GLOBAL_HXX +#pragma once #include "Multi.hxx" #include "event/CoarseTimerEvent.hxx" @@ -56,5 +55,3 @@ private: /* callback for #timeout_event */ void OnTimeout() noexcept; }; - -#endif diff --git a/src/lib/curl/Slist.hxx b/src/lib/curl/Slist.hxx index f1641aff0..b3b17149c 100644 --- a/src/lib/curl/Slist.hxx +++ b/src/lib/curl/Slist.hxx @@ -1,8 +1,7 @@ // SPDX-License-Identifier: BSD-2-Clause // author: Max Kellermann -#ifndef CURL_SLIST_HXX -#define CURL_SLIST_HXX +#pragma once #include @@ -47,5 +46,3 @@ public: head = new_head; } }; - -#endif diff --git a/src/lib/curl/String.hxx b/src/lib/curl/String.hxx index a21a2dcf2..c5f693083 100644 --- a/src/lib/curl/String.hxx +++ b/src/lib/curl/String.hxx @@ -1,8 +1,7 @@ // SPDX-License-Identifier: BSD-2-Clause // author: Max Kellermann -#ifndef CURL_STRING_HXX -#define CURL_STRING_HXX +#pragma once #include @@ -47,5 +46,3 @@ public: return p; } }; - -#endif diff --git a/src/lib/dbus/Connection.hxx b/src/lib/dbus/Connection.hxx index 9173401a8..7219a7450 100644 --- a/src/lib/dbus/Connection.hxx +++ b/src/lib/dbus/Connection.hxx @@ -2,8 +2,7 @@ // Copyright CM4all GmbH // author: Max Kellermann -#ifndef ODBUS_CONNECTION_HXX -#define ODBUS_CONNECTION_HXX +#pragma once #include @@ -61,5 +60,3 @@ public: }; } /* namespace ODBus */ - -#endif diff --git a/src/lib/dbus/Iter.hxx b/src/lib/dbus/Iter.hxx index e8a3ea627..3fb3075f0 100644 --- a/src/lib/dbus/Iter.hxx +++ b/src/lib/dbus/Iter.hxx @@ -2,8 +2,7 @@ // Copyright CM4all GmbH // author: Max Kellermann -#ifndef ODBUS_ITER_HXX -#define ODBUS_ITER_HXX +#pragma once #include @@ -21,5 +20,3 @@ public: }; } /* namespace ODBus */ - -#endif diff --git a/src/lib/dbus/Message.hxx b/src/lib/dbus/Message.hxx index 6a147f866..f3807a7b4 100644 --- a/src/lib/dbus/Message.hxx +++ b/src/lib/dbus/Message.hxx @@ -2,8 +2,7 @@ // Copyright CM4all GmbH // author: Max Kellermann -#ifndef ODBUS_MESSAGE_HXX -#define ODBUS_MESSAGE_HXX +#pragma once #include @@ -123,5 +122,3 @@ public: }; } /* namespace ODBus */ - -#endif diff --git a/src/lib/dbus/PendingCall.hxx b/src/lib/dbus/PendingCall.hxx index 62b4b3a54..77537f817 100644 --- a/src/lib/dbus/PendingCall.hxx +++ b/src/lib/dbus/PendingCall.hxx @@ -2,8 +2,7 @@ // Copyright CM4all GmbH // author: Max Kellermann -#ifndef ODBUS_PENDING_CALL_HXX -#define ODBUS_PENDING_CALL_HXX +#pragma once #include @@ -76,5 +75,3 @@ public: }; } /* namespace ODBus */ - -#endif diff --git a/src/lib/dbus/ScopeMatch.hxx b/src/lib/dbus/ScopeMatch.hxx index 7b54fe31d..0140c0caa 100644 --- a/src/lib/dbus/ScopeMatch.hxx +++ b/src/lib/dbus/ScopeMatch.hxx @@ -2,8 +2,7 @@ // Copyright CM4all GmbH // author: Max Kellermann -#ifndef ODBUS_SCOPE_MATCH_HXX -#define ODBUS_SCOPE_MATCH_HXX +#pragma once #include @@ -29,5 +28,3 @@ public: }; } /* namespace ODBus */ - -#endif diff --git a/src/lib/dbus/Types.hxx b/src/lib/dbus/Types.hxx index 7ba5d4fa8..1e6f476ab 100644 --- a/src/lib/dbus/Types.hxx +++ b/src/lib/dbus/Types.hxx @@ -2,8 +2,7 @@ // Copyright CM4all GmbH // author: Max Kellermann -#ifndef ODBUS_TYPES_HXX -#define ODBUS_TYPES_HXX +#pragma once #include "util/TemplateString.hxx" @@ -89,5 +88,3 @@ struct StructTypeTraits { }; } /* namespace ODBus */ - -#endif diff --git a/src/lib/zlib/Error.hxx b/src/lib/zlib/Error.hxx index b0853b250..745222037 100644 --- a/src/lib/zlib/Error.hxx +++ b/src/lib/zlib/Error.hxx @@ -1,8 +1,7 @@ // SPDX-License-Identifier: BSD-2-Clause // author: Max Kellermann -#ifndef ZLIB_ERROR_HXX -#define ZLIB_ERROR_HXX +#pragma once #include @@ -18,5 +17,3 @@ public: const char *what() const noexcept override; }; - -#endif diff --git a/src/lib/zlib/GunzipReader.hxx b/src/lib/zlib/GunzipReader.hxx index 5cc6bf915..c0c3e46ac 100644 --- a/src/lib/zlib/GunzipReader.hxx +++ b/src/lib/zlib/GunzipReader.hxx @@ -1,8 +1,7 @@ // SPDX-License-Identifier: BSD-2-Clause // author: Max Kellermann -#ifndef GUNZIP_READER_HXX -#define GUNZIP_READER_HXX +#pragma once #include "io/Reader.hxx" #include "util/StaticFifoBuffer.hxx" @@ -39,5 +38,3 @@ public: private: bool FillBuffer(); }; - -#endif diff --git a/src/net/IPv4Address.hxx b/src/net/IPv4Address.hxx index 36db16a22..407666b43 100644 --- a/src/net/IPv4Address.hxx +++ b/src/net/IPv4Address.hxx @@ -1,8 +1,7 @@ // SPDX-License-Identifier: BSD-2-Clause // author: Max Kellermann -#ifndef IPV4_ADDRESS_HXX -#define IPV4_ADDRESS_HXX +#pragma once #include "SocketAddress.hxx" #include "util/ByteOrder.hxx" @@ -209,5 +208,3 @@ public: GetPort() & other.GetPort()); } }; - -#endif diff --git a/src/net/IPv6Address.hxx b/src/net/IPv6Address.hxx index 80d848a41..cd04c7a46 100644 --- a/src/net/IPv6Address.hxx +++ b/src/net/IPv6Address.hxx @@ -1,8 +1,7 @@ // SPDX-License-Identifier: BSD-2-Clause // author: Max Kellermann -#ifndef IPV6_ADDRESS_HXX -#define IPV6_ADDRESS_HXX +#pragma once #include "SocketAddress.hxx" #include "util/ByteOrder.hxx" @@ -191,5 +190,3 @@ private: : (0xffff << (offset + 16 - prefix_length))); } }; - -#endif diff --git a/src/net/Resolver.hxx b/src/net/Resolver.hxx index c039fe0ac..303761a6d 100644 --- a/src/net/Resolver.hxx +++ b/src/net/Resolver.hxx @@ -2,8 +2,7 @@ // Copyright CM4all GmbH // author: Max Kellermann -#ifndef NET_RESOLVER_HXX -#define NET_RESOLVER_HXX +#pragma once class AddressInfoList; @@ -30,5 +29,3 @@ Resolve(const char *host_and_port, int default_port, AddressInfoList Resolve(const char *host_port, unsigned default_port, int flags, int socktype); - -#endif diff --git a/src/util/AllocatedString.hxx b/src/util/AllocatedString.hxx index dd095ede6..72d060756 100644 --- a/src/util/AllocatedString.hxx +++ b/src/util/AllocatedString.hxx @@ -1,8 +1,7 @@ // SPDX-License-Identifier: BSD-2-Clause // author: Max Kellermann -#ifndef ALLOCATED_STRING_HXX -#define ALLOCATED_STRING_HXX +#pragma once #include "StringPointer.hxx" @@ -164,5 +163,3 @@ public: using BasicAllocatedString::operator=; }; - -#endif diff --git a/src/util/Cast.hxx b/src/util/Cast.hxx index da6903345..1a2a2d0cb 100644 --- a/src/util/Cast.hxx +++ b/src/util/Cast.hxx @@ -1,8 +1,7 @@ // SPDX-License-Identifier: BSD-2-Clause // author: Max Kellermann -#ifndef CAST_HXX -#define CAST_HXX +#pragma once #include "OffsetPointer.hxx" @@ -55,5 +54,3 @@ ContainerCast(const A &a, const A C::*member) { return *OffsetCast(&a, -ContainerAttributeOffset(member)); } - -#endif diff --git a/src/util/CharUtil.hxx b/src/util/CharUtil.hxx index d599269bc..44fd9b3a7 100644 --- a/src/util/CharUtil.hxx +++ b/src/util/CharUtil.hxx @@ -1,8 +1,7 @@ // SPDX-License-Identifier: BSD-2-Clause // author: Max Kellermann -#ifndef CHAR_UTIL_HXX -#define CHAR_UTIL_HXX +#pragma once #ifdef _UNICODE #include "WCharUtil.hxx" @@ -140,5 +139,3 @@ IsHexDigit(char ch) noexcept (ch >= 'a' && ch <= 'f') || (ch >= 'A' && ch <= 'F'); } - -#endif diff --git a/src/util/DeleteDisposer.hxx b/src/util/DeleteDisposer.hxx index abc5ddda3..2201acfae 100644 --- a/src/util/DeleteDisposer.hxx +++ b/src/util/DeleteDisposer.hxx @@ -1,8 +1,7 @@ // SPDX-License-Identifier: BSD-2-Clause // author: Max Kellermann -#ifndef DELETE_DISPOSER_HXX -#define DELETE_DISPOSER_HXX +#pragma once /** * A disposer for boost::intrusive that invokes the "delete" operator @@ -15,5 +14,3 @@ public: delete t; } }; - -#endif diff --git a/src/util/DynamicFifoBuffer.hxx b/src/util/DynamicFifoBuffer.hxx index a249e47d4..e8a45d6b2 100644 --- a/src/util/DynamicFifoBuffer.hxx +++ b/src/util/DynamicFifoBuffer.hxx @@ -1,8 +1,7 @@ // SPDX-License-Identifier: BSD-2-Clause // author: Max Kellermann -#ifndef DYNAMIC_FIFO_BUFFER_HXX -#define DYNAMIC_FIFO_BUFFER_HXX +#pragma once #include "ForeignFifoBuffer.hxx" @@ -91,5 +90,3 @@ public: protected: using ForeignFifoBuffer::GetBuffer; }; - -#endif diff --git a/src/util/Exception.hxx b/src/util/Exception.hxx index b2ba122b0..44f323469 100644 --- a/src/util/Exception.hxx +++ b/src/util/Exception.hxx @@ -1,8 +1,7 @@ // SPDX-License-Identifier: BSD-2-Clause // author: Max Kellermann -#ifndef EXCEPTION_HXX -#define EXCEPTION_HXX +#pragma once #include #include @@ -113,5 +112,3 @@ std::string GetFullMessage(std::exception_ptr ep, const char *fallback="Unknown exception", const char *separator="; ") noexcept; - -#endif diff --git a/src/util/PrintException.hxx b/src/util/PrintException.hxx index ecf2f3756..6947041e6 100644 --- a/src/util/PrintException.hxx +++ b/src/util/PrintException.hxx @@ -2,8 +2,7 @@ // Copyright CM4all GmbH // author: Max Kellermann -#ifndef PRINT_EXCEPTION_HXX -#define PRINT_EXCEPTION_HXX +#pragma once #include @@ -15,5 +14,3 @@ PrintException(const std::exception &e) noexcept; void PrintException(const std::exception_ptr &ep) noexcept; - -#endif diff --git a/src/util/ScopeExit.hxx b/src/util/ScopeExit.hxx index 9e1cc5dde..2c2c9929e 100644 --- a/src/util/ScopeExit.hxx +++ b/src/util/ScopeExit.hxx @@ -1,8 +1,7 @@ // SPDX-License-Identifier: BSD-2-Clause // author: Max Kellermann -#ifndef SCOPE_EXIT_HXX -#define SCOPE_EXIT_HXX +#pragma once #include @@ -64,5 +63,3 @@ struct ScopeExitTag { * Boost's compile-time and runtime bloat. */ #define AtScopeExit(...) auto ScopeExitName(__LINE__) = ScopeExitTag() + [__VA_ARGS__]() - -#endif diff --git a/src/util/ShallowCopy.hxx b/src/util/ShallowCopy.hxx index e687783fa..411656c4a 100644 --- a/src/util/ShallowCopy.hxx +++ b/src/util/ShallowCopy.hxx @@ -2,8 +2,7 @@ // Copyright CM4all GmbH // author: Max Kellermann -#ifndef SHALLOW_COPY_HXX -#define SHALLOW_COPY_HXX +#pragma once /** * A tag for overloading copying constructors, telling them to make @@ -11,5 +10,3 @@ * duplicating the referenced objects). */ struct ShallowCopy {}; - -#endif diff --git a/src/util/StringAPI.hxx b/src/util/StringAPI.hxx index f090ad8b5..a38185d1f 100644 --- a/src/util/StringAPI.hxx +++ b/src/util/StringAPI.hxx @@ -1,8 +1,7 @@ // SPDX-License-Identifier: BSD-2-Clause // author: Max Kellermann -#ifndef STRING_API_HXX -#define STRING_API_HXX +#pragma once #include @@ -193,5 +192,3 @@ DuplicateString(const char *p) noexcept { return strdup(p); } - -#endif diff --git a/src/util/StringBuffer.hxx b/src/util/StringBuffer.hxx index 872ad11a3..e25d42cbb 100644 --- a/src/util/StringBuffer.hxx +++ b/src/util/StringBuffer.hxx @@ -1,8 +1,7 @@ // SPDX-License-Identifier: BSD-2-Clause // author: Max Kellermann -#ifndef STRING_BUFFER_HXX -#define STRING_BUFFER_HXX +#pragma once #include @@ -89,5 +88,3 @@ public: template class StringBuffer : public BasicStringBuffer {}; - -#endif diff --git a/src/util/StringPointer.hxx b/src/util/StringPointer.hxx index 0692d5c0d..7b7ba9685 100644 --- a/src/util/StringPointer.hxx +++ b/src/util/StringPointer.hxx @@ -1,8 +1,7 @@ // SPDX-License-Identifier: BSD-2-Clause // author: Max Kellermann -#ifndef STRING_POINTER_HXX -#define STRING_POINTER_HXX +#pragma once #include @@ -52,5 +51,3 @@ public: return *value == SENTINEL; } }; - -#endif