mirror of
https://github.com/Dasharo/edk2-upstream.git
synced 2026-06-13 19:16:19 -07:00
RedfishPkg: Replace include guards with #pragma once
Replace traditional `#ifndef`/`#define`/`#endif` include guards with
`#pragma` once.
`#pragma once` is a widely supported preprocessor directive that
prevents header files from being included multiple times. It is
supported by all toolchains used to build edk2: GCC, Clang/LLVM, and
MSVC.
Compared to macro-based include guards, `#pragma once`:
- Eliminates the risk of macro name collisions or copy/paste errors
where two headers inadvertently use the same guard macro.
- Eliminate inconsistency in the way include guard macros are named
(e.g., some files use `__FILE_H__`, others use `FILE_H_`, etc.).
- Reduces boilerplate (three lines replaced by one).
- Avoids polluting the macro namespace with guard symbols.
- Can improve build times as the preprocessor can skip re-opening the
file entirely, rather than re-reading it to find the matching
`#endif` ("multiple-include optimization").
- Note that some compilers may already optimize traditional include
guards, by recognzining the idiomatic pattern.
This change is made acknowledging that overall portability of the
code will technically be reduced, as `#pragma once` is not part of the
C/C++ standards.
However, this is considered acceptable given:
1. edk2 already defines a subset of supported compilers in
BaseTools/Conf/tools_def.template, all of which have supported
`#pragma once` for over two decades.
2. There have been concerns raised to the project about inconsistent
include guard naming and potential macro collisions.
Approximate compiler support dates:
- MSVC: Supported since Visual C++ 4.2 (1996)
- GCC: Supported since 3.4 (2004)
(http://gnu.ist.utl.pt/software/gcc/gcc-3.4/changes.html)
- Clang (LLVM based): Since initial release in 2007
Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
This commit is contained in:
committed by
mergify[bot]
parent
963162cab0
commit
6181c85fa9
@@ -8,8 +8,7 @@
|
||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
**/
|
||||
|
||||
#ifndef REDFISH_HOST_INTERFACE_
|
||||
#define REDFISH_HOST_INTERFACE_
|
||||
#pragma once
|
||||
|
||||
#include <IndustryStandard/SmBios.h>
|
||||
|
||||
@@ -187,5 +186,3 @@ typedef struct {
|
||||
} REDFISH_OVER_IP_PROTOCOL_DATA;
|
||||
|
||||
#pragma pack()
|
||||
|
||||
#endif
|
||||
|
||||
@@ -5,8 +5,7 @@
|
||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
**/
|
||||
|
||||
#ifndef REDFISH_HOST_INTERFACE_IPMI_H_
|
||||
#define REDFISH_HOST_INTERFACE_IPMI_H_
|
||||
#pragma once
|
||||
|
||||
#include <Uefi.h>
|
||||
#include <IndustryStandard/IpmiNetFnGroupExtension.h>
|
||||
@@ -47,5 +46,3 @@ typedef struct {
|
||||
} IPMI_BOOTSTRAP_CREDENTIALS_RESULT_RESPONSE;
|
||||
|
||||
#pragma pack()
|
||||
|
||||
#endif
|
||||
|
||||
@@ -8,8 +8,7 @@
|
||||
|
||||
**/
|
||||
|
||||
#ifndef BASE_UCS2UTF8_LIB_H_
|
||||
#define BASE_UCS2UTF8_LIB_H_
|
||||
#pragma once
|
||||
|
||||
///
|
||||
/// L"\u0000"
|
||||
@@ -57,5 +56,3 @@ UTF8StrToUCS2 (
|
||||
IN CHAR8 *Utf8Str,
|
||||
OUT CHAR16 **Ucs2StrAddr
|
||||
);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -9,8 +9,7 @@
|
||||
|
||||
**/
|
||||
|
||||
#ifndef HII_UTILITY_LIB_
|
||||
#define HII_UTILITY_LIB_
|
||||
#pragma once
|
||||
|
||||
#include <Protocol/DisplayProtocol.h>
|
||||
#include <Protocol/HiiConfigAccess.h>
|
||||
@@ -1200,5 +1199,3 @@ EvaluateExpressionList (
|
||||
IN HII_FORMSET *FormSet OPTIONAL,
|
||||
IN HII_FORM *Form OPTIONAL
|
||||
);
|
||||
|
||||
#endif // HII_UTILITY_LIB_
|
||||
|
||||
@@ -9,8 +9,7 @@
|
||||
|
||||
**/
|
||||
|
||||
#ifndef JSON_LIB_H_
|
||||
#define JSON_LIB_H_
|
||||
#pragma once
|
||||
|
||||
typedef VOID *EDKII_JSON_VALUE;
|
||||
typedef VOID *EDKII_JSON_ARRAY;
|
||||
@@ -944,5 +943,3 @@ EFIAPI
|
||||
JsonGetType (
|
||||
IN EDKII_JSON_VALUE JsonValue
|
||||
);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -7,8 +7,7 @@
|
||||
|
||||
**/
|
||||
|
||||
#ifndef REDFISH_CONTENT_CODING_LIB_H_
|
||||
#define REDFISH_CONTENT_CODING_LIB_H_
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
This is the function to encode the content use the
|
||||
@@ -76,5 +75,3 @@ RedfishContentDecode (
|
||||
OUT VOID **DecodedContentPointer,
|
||||
OUT UINTN *DecodedLength
|
||||
);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -7,8 +7,7 @@
|
||||
|
||||
**/
|
||||
|
||||
#ifndef REDFISH_CREDENTIAL_LIB_H_
|
||||
#define REDFISH_CREDENTIAL_LIB_H_
|
||||
#pragma once
|
||||
|
||||
#include <Uefi.h>
|
||||
|
||||
@@ -89,5 +88,3 @@ LibStopRedfishService (
|
||||
IN EDKII_REDFISH_CREDENTIAL_PROTOCOL *This,
|
||||
IN EDKII_REDFISH_CREDENTIAL_STOP_SERVICE_TYPE ServiceStopType
|
||||
);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -8,8 +8,7 @@
|
||||
|
||||
**/
|
||||
|
||||
#ifndef REDFISH_CRT_LIB_H_
|
||||
#define REDFISH_CRT_LIB_H_
|
||||
#pragma once
|
||||
|
||||
#include <Library/BaseLib.h>
|
||||
#include <Library/BaseMemoryLib.h>
|
||||
@@ -405,5 +404,3 @@ time (
|
||||
extern int errno;
|
||||
|
||||
#define ERANGE 34 /* 34 Result too large */
|
||||
|
||||
#endif
|
||||
|
||||
@@ -8,8 +8,7 @@
|
||||
|
||||
**/
|
||||
|
||||
#ifndef REDFISH_DEBUG_LIB_H_
|
||||
#define REDFISH_DEBUG_LIB_H_
|
||||
#pragma once
|
||||
|
||||
#include <Uefi.h>
|
||||
#include <Library/DebugLib.h>
|
||||
@@ -176,5 +175,3 @@ DumpBuffer (
|
||||
IN UINT8 *Buffer,
|
||||
IN UINTN BufferSize
|
||||
);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -9,8 +9,7 @@
|
||||
|
||||
**/
|
||||
|
||||
#ifndef REDFISH_HOST_INTERFACE_LIB_H_
|
||||
#define REDFISH_HOST_INTERFACE_LIB_H_
|
||||
#pragma once
|
||||
|
||||
#include <Uefi.h>
|
||||
#include <IndustryStandard/RedfishHostInterface.h>
|
||||
@@ -87,5 +86,3 @@ EFI_STATUS
|
||||
RedfishPlatformHostInterfaceSerialNumber (
|
||||
OUT CHAR8 **SerialNumber
|
||||
);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -7,8 +7,7 @@
|
||||
|
||||
**/
|
||||
|
||||
#ifndef REDFISH_HTTP_LIB_H_
|
||||
#define REDFISH_HTTP_LIB_H_
|
||||
#pragma once
|
||||
|
||||
#include <Protocol/EdkIIRedfishHttpProtocol.h>
|
||||
|
||||
@@ -322,5 +321,3 @@ RedfishHttpDeleteResourceEx (
|
||||
IN CHAR8 *ContentType OPTIONAL,
|
||||
OUT REDFISH_RESPONSE *Response
|
||||
);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -67,8 +67,7 @@
|
||||
|
||||
**/
|
||||
|
||||
#ifndef REDFISH_LIB_H_
|
||||
#define REDFISH_LIB_H_
|
||||
#pragma once
|
||||
|
||||
#include <RedfishServiceData.h>
|
||||
#include <Library/JsonLib.h>
|
||||
@@ -736,5 +735,3 @@ RedfishBuildRedpathUseId (
|
||||
IN CHAR8 *Id,
|
||||
OUT CHAR8 **Redpath
|
||||
);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -8,8 +8,7 @@
|
||||
|
||||
**/
|
||||
|
||||
#ifndef REDFISH_PLATFORM_CONFIG_LIB_H_
|
||||
#define REDFISH_PLATFORM_CONFIG_LIB_H_
|
||||
#pragma once
|
||||
|
||||
#include <Protocol/EdkIIRedfishPlatformConfig.h>
|
||||
|
||||
@@ -139,5 +138,3 @@ RedfishPlatformConfigGetDefaultValue (
|
||||
IN UINT16 DefaultClass,
|
||||
OUT EDKII_REDFISH_VALUE *Value
|
||||
);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -7,8 +7,7 @@
|
||||
|
||||
**/
|
||||
|
||||
#ifndef REDFISH_PLATFORM_WANTED_DEVICE_LIB_H_
|
||||
#define REDFISH_PLATFORM_WANTED_DEVICE_LIB_H_
|
||||
#pragma once
|
||||
|
||||
#include <Uefi.h>
|
||||
|
||||
@@ -33,5 +32,3 @@ IsPlatformWantedDevice (
|
||||
IN EFI_HANDLE ControllerHandle,
|
||||
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
|
||||
);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -8,8 +8,7 @@
|
||||
|
||||
**/
|
||||
|
||||
#ifndef REST_EX_LIB_H_
|
||||
#define REST_EX_LIB_H_
|
||||
#pragma once
|
||||
|
||||
#include <Protocol/RestEx.h>
|
||||
|
||||
@@ -41,5 +40,3 @@ RestExLibCreateChild (
|
||||
IN EFI_REST_EX_SERVICE_TYPE ServiceType,
|
||||
OUT EFI_HANDLE *ChildInstanceHandle
|
||||
);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -10,8 +10,7 @@
|
||||
|
||||
**/
|
||||
|
||||
#ifndef REST_EX_SERVICE_DEVICE_PATH_H_
|
||||
#define REST_EX_SERVICE_DEVICE_PATH_H_
|
||||
#pragma once
|
||||
|
||||
#include <Protocol/DevicePath.h>
|
||||
|
||||
@@ -37,5 +36,3 @@ typedef struct {
|
||||
//
|
||||
EFI_DEVICE_PATH_PROTOCOL DevicePath[MAX_DEVICE_PATH_NODE];
|
||||
} REST_EX_SERVICE_DEVICE_PATH_DATA;
|
||||
|
||||
#endif
|
||||
|
||||
@@ -8,8 +8,7 @@
|
||||
|
||||
**/
|
||||
|
||||
#ifndef EDKII_REDFISH_CONFIG_HANDLER_H_
|
||||
#define EDKII_REDFISH_CONFIG_HANDLER_H_
|
||||
#pragma once
|
||||
|
||||
typedef struct _EDKII_REDFISH_CONFIG_HANDLER_PROTOCOL EDKII_REDFISH_CONFIG_HANDLER_PROTOCOL;
|
||||
|
||||
@@ -73,5 +72,3 @@ struct _EDKII_REDFISH_CONFIG_HANDLER_PROTOCOL {
|
||||
};
|
||||
|
||||
extern EFI_GUID gdkIIRedfishConfigHandlerProtocolGuid;
|
||||
|
||||
#endif
|
||||
|
||||
@@ -8,8 +8,7 @@
|
||||
|
||||
**/
|
||||
|
||||
#ifndef EDKII_REDFISH_CREDENTIAL_H_
|
||||
#define EDKII_REDFISH_CREDENTIAL_H_
|
||||
#pragma once
|
||||
|
||||
typedef struct _EDKII_REDFISH_CREDENTIAL_PROTOCOL EDKII_REDFISH_CREDENTIAL_PROTOCOL;
|
||||
|
||||
@@ -96,5 +95,3 @@ struct _EDKII_REDFISH_CREDENTIAL_PROTOCOL {
|
||||
};
|
||||
|
||||
extern EFI_GUID gEdkIIRedfishCredentialProtocolGuid;
|
||||
|
||||
#endif
|
||||
|
||||
@@ -9,8 +9,7 @@
|
||||
|
||||
**/
|
||||
|
||||
#ifndef EDKII_REDFISH_CREDENTIAL2_H_
|
||||
#define EDKII_REDFISH_CREDENTIAL2_H_
|
||||
#pragma once
|
||||
|
||||
#include <Protocol/EdkIIRedfishCredential.h>
|
||||
#include <RedfishServiceData.h>
|
||||
@@ -124,5 +123,3 @@ struct _EDKII_REDFISH_CREDENTIAL2_PROTOCOL {
|
||||
};
|
||||
|
||||
extern EFI_GUID gEdkIIRedfishCredential2ProtocolGuid;
|
||||
|
||||
#endif
|
||||
|
||||
@@ -7,8 +7,7 @@
|
||||
|
||||
**/
|
||||
|
||||
#ifndef EDKII_REDFISH_HTTP_PROTOCOL_H_
|
||||
#define EDKII_REDFISH_HTTP_PROTOCOL_H_
|
||||
#pragma once
|
||||
|
||||
#include <RedfishServiceData.h>
|
||||
#include <Library/JsonLib.h>
|
||||
@@ -304,5 +303,3 @@ struct _EDKII_REDFISH_HTTP_PROTOCOL {
|
||||
#define EDKII_REDFISH_HTTP_PROTOCOL_REVISION 0x00001000
|
||||
|
||||
extern EFI_GUID gEdkIIRedfishHttpProtocolGuid;
|
||||
|
||||
#endif
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user