Add header guards missing in some files

Some header files, such as those which define structures or classes,
cannot be included more than once within a translation unit, as doing
so would cause a redefinition error. Such headers must be guarded to
prevent ill-effects from multiple inclusion. Similarly, if header
files include other header files, and this inclusion graph contains
a cycle, then at least one file within the cycle must contain header
guards in order to break the cycle. Because of cases like these, all
headers should be guarded as a matter of good practice, even if they
do not strictly need to be.

Furthermore, most modern compilers contain optimizations which are
triggered by header guards. If the header guard strictly conforms
to the pattern that compilers expect, then inclusions of that
header other than the first have absolutely no effect: the file
isn't re-read from disk, nor is it re-tokenised or re-preprocessed.
This can result in a noticeable, albeit minor, improvement to
compilation time.

Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
This commit is contained in:
Michael Kubacki 2023-12-12 14:42:15 -05:00
Родитель c67a13efe7
Коммит 3d3b828364
4 изменённых файлов: 20 добавлений и 0 удалений

Просмотреть файл

@ -12,6 +12,9 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
**/
#ifndef DEVICE_SPECIFIC_BUS_INFO_LIB_H_
#define DEVICE_SPECIFIC_BUS_INFO_LIB_H_
typedef enum {
Ignore, // Do not check link speed
Gen1, // 2.5 GT/s
@ -72,3 +75,5 @@ ProcessPciDeviceResults (
IN UINTN ResultCount,
IN DEVICE_PCI_CHECK_RESULT *Results
);
#endif

Просмотреть файл

@ -8,6 +8,9 @@ Copyright (c) Microsoft Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
#ifndef CREATOR_ID_PARSER_H_
#define CREATOR_ID_PARSER_H_
/**
* Parses the Creator ID which, for now, just prints the GUID
*
@ -19,3 +22,5 @@ VOID
ParseCreatorID (
IN CONST EFI_GUID *CreatorID
);
#endif

Просмотреть файл

@ -9,6 +9,9 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
**/
#ifndef PLATFORM_ID_PARSER_H_
#define PLATFORM_ID_PARSER_H_
/**
* Parses the Platform/Source ID
*
@ -20,3 +23,5 @@ VOID
ParseSourceID (
IN CONST EFI_GUID *SourceID
);
#endif

Просмотреть файл

@ -4,6 +4,9 @@ Copyright (C) Microsoft Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
#ifndef CHECK_HW_ERR_REC_HEADER_LIB_H_
#define CHECK_HW_ERR_REC_HEADER_LIB_H_
/**
* Checks that all length and offset fields within the HWErrRec fall within the bounds of
* the buffer, all section data is accounted for in their respective section headers, and that
@ -21,3 +24,5 @@ ValidateCperHeader (
IN CONST EFI_COMMON_ERROR_RECORD_HEADER *Err,
IN CONST UINTN Size
);
#endif