You've already forked edk2-upstream
mirror of
https://github.com/Dasharo/edk2-upstream.git
synced 2026-03-06 15:03:57 -08:00
ShellPkg: 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
9326c0eb0a
commit
8472271dae
@@ -5,8 +5,7 @@
|
||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
**/
|
||||
|
||||
#ifndef _CONSOLE_LOGGER_HEADER_
|
||||
#define _CONSOLE_LOGGER_HEADER_
|
||||
#pragma once
|
||||
|
||||
#include "Shell.h"
|
||||
|
||||
@@ -312,5 +311,3 @@ EFI_STATUS
|
||||
ConsoleLoggerResetBuffers (
|
||||
IN CONSOLE_LOGGER_PRIVATE_DATA *ConsoleInfo
|
||||
);
|
||||
|
||||
#endif //_CONSOLE_LOGGER_HEADER_
|
||||
|
||||
@@ -7,8 +7,7 @@
|
||||
|
||||
**/
|
||||
|
||||
#ifndef _SHELL_CONSOLE_WRAPPERS_HEADER_
|
||||
#define _SHELL_CONSOLE_WRAPPERS_HEADER_
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
Function to create a EFI_SIMPLE_TEXT_INPUT_PROTOCOL on top of a
|
||||
@@ -69,5 +68,3 @@ EFI_STATUS
|
||||
CloseSimpleTextOutOnFile (
|
||||
IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *SimpleTextOut
|
||||
);
|
||||
|
||||
#endif //_SHELL_CONSOLE_WRAPPERS_HEADER_
|
||||
|
||||
@@ -6,8 +6,7 @@
|
||||
|
||||
**/
|
||||
|
||||
#ifndef _FILE_HANDLE_INTERNAL_HEADER_
|
||||
#define _FILE_HANDLE_INTERNAL_HEADER_
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
Move the cursor position one character backward.
|
||||
@@ -54,5 +53,3 @@ PrintCommandHistory (
|
||||
IN CONST UINTN TotalRows,
|
||||
IN CONST UINTN StartColumn
|
||||
);
|
||||
|
||||
#endif //_FILE_HANDLE_INTERNAL_HEADER_
|
||||
|
||||
@@ -6,8 +6,7 @@
|
||||
|
||||
**/
|
||||
|
||||
#ifndef _SHELL_FILE_HANDLE_WRAPPERS_HEADER_
|
||||
#define _SHELL_FILE_HANDLE_WRAPPERS_HEADER_
|
||||
#pragma once
|
||||
|
||||
typedef struct {
|
||||
LIST_ENTRY Link;
|
||||
@@ -82,5 +81,3 @@ CreateFileInterfaceFile (
|
||||
IN CONST EFI_FILE_PROTOCOL *Template,
|
||||
IN CONST BOOLEAN Unicode
|
||||
);
|
||||
|
||||
#endif //_SHELL_FILE_HANDLE_WRAPPERS_HEADER_
|
||||
|
||||
@@ -7,8 +7,7 @@
|
||||
|
||||
**/
|
||||
|
||||
#ifndef _SHELL_INTERNAL_HEADER_
|
||||
#define _SHELL_INTERNAL_HEADER_
|
||||
#pragma once
|
||||
|
||||
#include <Uefi.h>
|
||||
|
||||
@@ -382,5 +381,3 @@ VOID
|
||||
RestoreBufferList (
|
||||
IN OUT LIST_ENTRY *OldBufferList
|
||||
);
|
||||
|
||||
#endif //_SHELL_INTERNAL_HEADER_
|
||||
|
||||
@@ -11,8 +11,7 @@
|
||||
|
||||
**/
|
||||
|
||||
#ifndef _SHELL_ENVIRONMENT_VARIABLE_HEADER_
|
||||
#define _SHELL_ENVIRONMENT_VARIABLE_HEADER_
|
||||
#pragma once
|
||||
|
||||
typedef struct {
|
||||
LIST_ENTRY Link;
|
||||
@@ -276,5 +275,3 @@ VOID
|
||||
ShellFreeEnvVarList (
|
||||
VOID
|
||||
);
|
||||
|
||||
#endif //_SHELL_ENVIRONMENT_VARIABLE_HEADER_
|
||||
|
||||
@@ -6,8 +6,7 @@
|
||||
|
||||
**/
|
||||
|
||||
#ifndef _SHELL_MAN_FILE_PARSER_HEADER_
|
||||
#define _SHELL_MAN_FILE_PARSER_HEADER_
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
This function returns the help information for the specified command. The help text
|
||||
@@ -73,5 +72,3 @@ ManFileFindSections (
|
||||
OUT UINTN *HelpSize,
|
||||
IN BOOLEAN Ascii
|
||||
);
|
||||
|
||||
#endif //_SHELL_MAN_FILE_PARSER_HEADER_
|
||||
|
||||
@@ -7,8 +7,7 @@
|
||||
|
||||
**/
|
||||
|
||||
#ifndef _SHELL_PARAMETERS_PROTOCOL_PROVIDER_HEADER_
|
||||
#define _SHELL_PARAMETERS_PROTOCOL_PROVIDER_HEADER_
|
||||
#pragma once
|
||||
|
||||
#include "Shell.h"
|
||||
|
||||
@@ -206,5 +205,3 @@ GetNextParameter (
|
||||
IN CONST UINTN Length,
|
||||
IN BOOLEAN StripQuotation
|
||||
);
|
||||
|
||||
#endif //_SHELL_PARAMETERS_PROTOCOL_PROVIDER_HEADER_
|
||||
|
||||
@@ -8,8 +8,7 @@
|
||||
|
||||
**/
|
||||
|
||||
#ifndef _SHELL_PROTOCOL_HEADER_
|
||||
#define _SHELL_PROTOCOL_HEADER_
|
||||
#pragma once
|
||||
|
||||
#include "Shell.h"
|
||||
|
||||
@@ -934,5 +933,3 @@ EFIAPI
|
||||
NotificationFunction (
|
||||
IN EFI_KEY_DATA *KeyData
|
||||
);
|
||||
|
||||
#endif //_SHELL_PROTOCOL_HEADER_
|
||||
|
||||
@@ -6,8 +6,7 @@
|
||||
|
||||
**/
|
||||
|
||||
#ifndef _DP_H_
|
||||
#define _DP_H_
|
||||
#pragma once
|
||||
|
||||
#include <Uefi.h>
|
||||
|
||||
@@ -136,5 +135,3 @@ EFI_HII_HANDLE
|
||||
InitializeHiiPackage (
|
||||
EFI_HANDLE ImageHandle
|
||||
);
|
||||
|
||||
#endif // _DP_H_
|
||||
|
||||
@@ -11,8 +11,7 @@
|
||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
**/
|
||||
|
||||
#ifndef _DP_INTELNAL_H_
|
||||
#define _DP_INTELNAL_H_
|
||||
#pragma once
|
||||
|
||||
#define DP_GAUGE_STRING_LENGTH 36
|
||||
|
||||
@@ -311,5 +310,3 @@ VOID
|
||||
ProcessCumulative (
|
||||
IN PERF_CUM_DATA *CustomCumulativeData OPTIONAL
|
||||
);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -5,8 +5,7 @@
|
||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
**/
|
||||
|
||||
#ifndef _LITERALS_H_
|
||||
#define _LITERALS_H_
|
||||
#pragma once
|
||||
|
||||
// ASCII String literals which probably don't need translation
|
||||
extern CHAR8 const ALit_TimerLibError[];
|
||||
@@ -23,5 +22,3 @@ extern CHAR8 const ALit_DB_SUPPORT[];
|
||||
extern CHAR8 const ALit_DB_STOP[];
|
||||
extern CHAR8 const ALit_BdsTO[];
|
||||
extern CHAR8 const ALit_PEIM[];
|
||||
|
||||
#endif // _LITERALS_H_
|
||||
|
||||
@@ -9,8 +9,7 @@
|
||||
|
||||
**/
|
||||
|
||||
#ifndef _HTTP_H_
|
||||
#define _HTTP_H_
|
||||
#pragma once
|
||||
|
||||
#include <Uefi.h>
|
||||
|
||||
@@ -89,5 +88,3 @@ EFI_HII_HANDLE
|
||||
InitializeHiiPackage (
|
||||
IN EFI_HANDLE ImageHandle
|
||||
);
|
||||
|
||||
#endif // _HTTP_H_
|
||||
|
||||
@@ -8,8 +8,7 @@
|
||||
|
||||
**/
|
||||
|
||||
#ifndef _TFTP_H_
|
||||
#define _TFTP_H_
|
||||
#pragma once
|
||||
|
||||
#include <Uefi.h>
|
||||
|
||||
@@ -66,5 +65,3 @@ EFI_HII_HANDLE
|
||||
InitializeHiiPackage (
|
||||
EFI_HANDLE ImageHandle
|
||||
);
|
||||
|
||||
#endif // _TFTP_H_
|
||||
|
||||
@@ -6,8 +6,7 @@
|
||||
|
||||
**/
|
||||
|
||||
#ifndef VAR_POLICY_DYNAMIC_SHELL_COMMAND_H_
|
||||
#define VAR_POLICY_DYNAMIC_SHELL_COMMAND_H_
|
||||
#pragma once
|
||||
|
||||
#include <Uefi.h>
|
||||
#include <Protocol/Shell.h>
|
||||
@@ -125,5 +124,3 @@ RunVarPolicy (
|
||||
IN EFI_HANDLE ImageHandle,
|
||||
IN EFI_SYSTEM_TABLE *SystemTable
|
||||
);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -6,8 +6,7 @@
|
||||
|
||||
**/
|
||||
|
||||
#ifndef _SHELL_ALIAS_VARIABLE_GUID_H_
|
||||
#define _SHELL_ALIAS_VARIABLE_GUID_H_
|
||||
#pragma once
|
||||
|
||||
#define SHELL_ALIAS_VARIABLE_GUID \
|
||||
{ \
|
||||
@@ -15,5 +14,3 @@
|
||||
}
|
||||
|
||||
extern EFI_GUID gShellAliasGuid;
|
||||
|
||||
#endif
|
||||
|
||||
@@ -6,8 +6,7 @@
|
||||
|
||||
**/
|
||||
|
||||
#ifndef _SHELLPKG_SHELL_ENV2_EXT_GUID_H_
|
||||
#define _SHELLPKG_SHELL_ENV2_EXT_GUID_H_
|
||||
#pragma once
|
||||
|
||||
#define SHELLPKG_SHELL_ENV2_EXT_GUID \
|
||||
{ \
|
||||
@@ -15,5 +14,3 @@
|
||||
}
|
||||
|
||||
extern EFI_GUID gEfiShellEnvironment2ExtGuid;
|
||||
|
||||
#endif
|
||||
|
||||
@@ -6,8 +6,7 @@
|
||||
|
||||
**/
|
||||
|
||||
#ifndef _SHELLLIB_HII_GUID_H_
|
||||
#define _SHELLLIB_HII_GUID_H_
|
||||
#pragma once
|
||||
|
||||
#define HANDLE_PARSING_HII_GUID \
|
||||
{ \
|
||||
@@ -81,5 +80,3 @@ extern EFI_GUID gShellNetwork2HiiGuid;
|
||||
extern EFI_GUID gShellTftpHiiGuid;
|
||||
extern EFI_GUID gShellHttpHiiGuid;
|
||||
extern EFI_GUID gShellBcfgHiiGuid;
|
||||
|
||||
#endif
|
||||
|
||||
@@ -6,8 +6,7 @@
|
||||
|
||||
**/
|
||||
|
||||
#ifndef _SHELL_MAP_GUID_H_
|
||||
#define _SHELL_MAP_GUID_H_
|
||||
#pragma once
|
||||
|
||||
#define SHELL_MAP_GUID \
|
||||
{ \
|
||||
@@ -15,5 +14,3 @@
|
||||
}
|
||||
|
||||
extern EFI_GUID gShellMapGuid;
|
||||
|
||||
#endif
|
||||
|
||||
@@ -6,8 +6,7 @@
|
||||
|
||||
**/
|
||||
|
||||
#ifndef _SHELLPKG_TOKEN_SPACE_GUID_H_
|
||||
#define _SHELLPKG_TOKEN_SPACE_GUID_H_
|
||||
#pragma once
|
||||
|
||||
#define EFI_SHELLPKG_TOKEN_SPACE_GUID \
|
||||
{ \
|
||||
@@ -15,5 +14,3 @@
|
||||
}
|
||||
|
||||
extern EFI_GUID gEfiShellPkgTokenSpaceGuid;
|
||||
|
||||
#endif
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user