On 08.01.21 15:43, [ext] Christian Storm wrote: > From: Christian Storm <[email protected]> > > Any modern compiler (e.g., gcc > 3.4, released 2004) > supports #pragma once -- and it doesn't pollute the > namespace with a preprocessor symbol. > So, get rid of overly verbose include guards.
Interesting. I wonder why the kernel isn't using it widely yet. I only find it in one of its tools. Maybe the reason is the limitations of #pragma once when it comes to identifying the same file included from different locations (via links etc.). I do not really expect any such complex cases with our simple API (ebgenv.h), and internal stuff is under our control, so it should be fine in this specific case. Jan > > Signed-off-by: Christian Storm <[email protected]> > --- > include/bootguard.h | 4 +--- > include/configuration.h | 4 +--- > include/ebgenv.h | 4 +--- > include/ebgpart.h | 4 +--- > include/env_api.h | 4 +--- > include/env_config_file.h | 4 +--- > include/env_config_partitions.h | 4 +--- > include/env_disk_utils.h | 4 +--- > include/envdata.h | 4 +--- > include/syspart.h | 4 +--- > include/test-interface.h | 5 +---- > include/uservars.h | 5 +---- > include/utils.h | 4 +--- > tools/tests/fake_devices.h | 4 +--- > 14 files changed, 14 insertions(+), 44 deletions(-) > > diff --git a/include/bootguard.h b/include/bootguard.h > index bf244a4..159a396 100644 > --- a/include/bootguard.h > +++ b/include/bootguard.h > @@ -12,8 +12,7 @@ > * SPDX-License-Identifier: GPL-2.0 > */ > > -#ifndef __H_BOOTGUARD__ > -#define __H_BOOTGUARD__ > +#pragma once > > #if defined(__GNUC__) > #define __noreturn __attribute__((noreturn)) > @@ -58,4 +57,3 @@ typedef struct _BG_LOADER_PARAMS { > UINTN timeout; > } BG_LOADER_PARAMS; > > -#endif // __H_BOOTGUARD__ > diff --git a/include/configuration.h b/include/configuration.h > index 34a1054..9f1425e 100644 > --- a/include/configuration.h > +++ b/include/configuration.h > @@ -12,8 +12,7 @@ > * SPDX-License-Identifier: GPL-2.0 > */ > > -#ifndef __H_CONFIG__ > -#define __H_CONFIG__ > +#pragma once > > #include <efi.h> > #include <efilib.h> > @@ -24,4 +23,3 @@ > BG_STATUS load_config(BG_LOADER_PARAMS *bg_loader_params); > BG_STATUS save_config(BG_LOADER_PARAMS *bg_loader_params); > > -#endif // __H_CONFIG__ > diff --git a/include/ebgenv.h b/include/ebgenv.h > index 67e2686..95b5bd4 100644 > --- a/include/ebgenv.h > +++ b/include/ebgenv.h > @@ -14,8 +14,7 @@ > * > */ > > -#ifndef __EBGENV_H__ > -#define __EBGENV_H__ > +#pragma once > > #include <errno.h> > > @@ -144,4 +143,3 @@ int ebg_env_register_gc_var(ebgenv_t *e, char *key); > */ > int ebg_env_finalize_update(ebgenv_t *e); > > -#endif //__EBGENV_H__ > diff --git a/include/ebgpart.h b/include/ebgpart.h > index a2b7552..d02cfbe 100644 > --- a/include/ebgpart.h > +++ b/include/ebgpart.h > @@ -16,8 +16,7 @@ > * partition tables. > */ > > -#ifndef __EBGPART_H__ > -#define __EBGPART_H__ > +#pragma once > > #ifndef _LARGEFILE64_SOURCE > #define _LARGEFILE64_SOURCE > @@ -141,4 +140,3 @@ PedPartition *ped_disk_next_partition(const PedDisk *pd, > > void ebgpart_beverbose(bool v); > > -#endif // __EBGPART_H__ > diff --git a/include/env_api.h b/include/env_api.h > index 9a5c2a8..eccfd4e 100644 > --- a/include/env_api.h > +++ b/include/env_api.h > @@ -12,8 +12,7 @@ > * SPDX-License-Identifier: GPL-2.0 > */ > > -#ifndef __ENV_API_H__ > -#define __ENV_API_H__ > +#pragma once > > #include <stddef.h> > #include <stdint.h> > @@ -94,4 +93,3 @@ extern int bgenv_set(BGENV *env, char *key, uint64_t type, > void *data, > uint32_t datalen); > extern uint8_t *bgenv_find_uservar(uint8_t *userdata, char *key); > > -#endif // __ENV_API_H__ > diff --git a/include/env_config_file.h b/include/env_config_file.h > index 2679174..081c922 100644 > --- a/include/env_config_file.h > +++ b/include/env_config_file.h > @@ -12,12 +12,10 @@ > * SPDX-License-Identifier: GPL-2.0 > */ > > -#ifndef __ENV_CONFIG_FILE_H__ > -#define __ENV_CONFIG_FILE_H__ > +#pragma once > > FILE *open_config_file_from_part(CONFIG_PART *cfgpart, char *mode); > FILE *open_config_file(char *configfilepath, char *mode); > int close_config_file(FILE *config_file_handle); > bool probe_config_file(CONFIG_PART *cfgpart); > > -#endif // __ENV_CONFIG_FILE_H__ > diff --git a/include/env_config_partitions.h b/include/env_config_partitions.h > index ebe6712..c6cd033 100644 > --- a/include/env_config_partitions.h > +++ b/include/env_config_partitions.h > @@ -12,9 +12,7 @@ > * SPDX-License-Identifier: GPL-2.0 > */ > > -#ifndef __ENV_CONFIG_PARTITIONS_H__ > -#define __ENV_CONFIG_PARTITIONS_H__ > +#pragma once > > bool probe_config_partitions(CONFIG_PART *cfgpart); > > -#endif // __ENV_CONFIG_PARTITIONS_H__ > diff --git a/include/env_disk_utils.h b/include/env_disk_utils.h > index 7450f20..eafdb59 100644 > --- a/include/env_disk_utils.h > +++ b/include/env_disk_utils.h > @@ -12,11 +12,9 @@ > * SPDX-License-Identifier: GPL-2.0 > */ > > -#ifndef __ENV_DISK_UTILS_H__ > -#define __ENV_DISK_UTILS_H__ > +#pragma once > > char *get_mountpoint(char *devpath); > bool mount_partition(CONFIG_PART *cfgpart); > void unmount_partition(CONFIG_PART *cfgpart); > > -#endif // __ENV_DISK_UTILS_H__ > diff --git a/include/envdata.h b/include/envdata.h > index 13cdb8d..e1f6195 100644 > --- a/include/envdata.h > +++ b/include/envdata.h > @@ -12,8 +12,7 @@ > * SPDX-License-Identifier: GPL-2.0 > */ > > -#ifndef __H_ENV_DATA__ > -#define __H_ENV_DATA__ > +#pragma once > > #define FAT_ENV_FILENAME "BGENV.DAT" > #define ENV_STRING_LENGTH 255 > @@ -45,4 +44,3 @@ struct _BG_ENVDATA { > > typedef struct _BG_ENVDATA BG_ENVDATA; > > -#endif // __H_ENV_DATA__ > diff --git a/include/syspart.h b/include/syspart.h > index b22577b..a96b3b1 100644 > --- a/include/syspart.h > +++ b/include/syspart.h > @@ -12,8 +12,7 @@ > * SPDX-License-Identifier: GPL-2.0 > */ > > -#ifndef __H_SYSPART__ > -#define __H_SYSPART__ > +#pragma once > > #include <efi.h> > #include <efilib.h> > @@ -35,4 +34,3 @@ > EFI_STATUS enumerate_cfg_parts(UINTN *config_volumes, UINTN *maxHandles); > UINTN filter_cfg_parts(UINTN *config_volumes, UINTN maxHandles); > > -#endif // __H_SYSPART__ > diff --git a/include/test-interface.h b/include/test-interface.h > index 9adbf56..9d43b1f 100644 > --- a/include/test-interface.h > +++ b/include/test-interface.h > @@ -12,8 +12,7 @@ > * SPDX-License-Identifier: GPL-2.0 > */ > > -#ifndef __TEST_INTERFACE_H__ > -#define __TEST_INTERFACE_H__ > +#pragma once > > #include "env_api.h" > > @@ -25,5 +24,3 @@ bool probe_config_partitions(CONFIG_PART *cfgparts); > bool mount_partition(CONFIG_PART *cfgpart); > > EBGENVKEY bgenv_str2enum(char *key); > - > -#endif // __TEST_INTERFACE_H__ > diff --git a/include/uservars.h b/include/uservars.h > index 11783a7..f2f3587 100644 > --- a/include/uservars.h > +++ b/include/uservars.h > @@ -12,8 +12,7 @@ > * SPDX-License-Identifier: GPL-2.0 > */ > > -#ifndef __USER_VARS_H__ > -#define __USER_VARS_H__ > +#pragma once > > #include <stdint.h> > > @@ -36,5 +35,3 @@ uint8_t *bgenv_uservar_realloc(uint8_t *udata, uint32_t > new_rsize, > uint8_t *p); > void bgenv_del_uservar(uint8_t *udata, uint8_t *var); > uint32_t bgenv_user_free(uint8_t *udata); > - > -#endif // __USER_VARS_H__ > diff --git a/include/utils.h b/include/utils.h > index 8978ec9..2f4fa87 100644 > --- a/include/utils.h > +++ b/include/utils.h > @@ -13,8 +13,7 @@ > * SPDX-License-Identifier: GPL-2.0 > */ > > -#ifndef __H_UTILS__ > -#define __H_UTILS__ > +#pragma once > > #include "bootguard.h" > > @@ -61,4 +60,3 @@ VOID PrintC(const UINT8 color, const CHAR16 *fmt, ...); > PrintC(EFI_LIGHTGRAY, fmt, ##__VA_ARGS__); \ > } while (0) > > -#endif // __H_UTILS__ > diff --git a/tools/tests/fake_devices.h b/tools/tests/fake_devices.h > index 40a8de1..4b03a36 100644 > --- a/tools/tests/fake_devices.h > +++ b/tools/tests/fake_devices.h > @@ -12,8 +12,7 @@ > * SPDX-License-Identifier: GPL-2.0 > */ > > -#ifndef __FAKE_DEVICES_H__ > -#define __FAKE_DEVICES_H__ > +#pragma once > > #include <ebgpart.h> > > @@ -27,4 +26,3 @@ void free_fake_devices(void); > > PedDevice *ped_device_get_next_custom_fake(const PedDevice *dev); > > -#endif // __FAKE_DEVICES_H__ > -- Siemens AG, T RDA IOT Corporate Competence Center Embedded Linux -- You received this message because you are subscribed to the Google Groups "EFI Boot Guard" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/efibootguard-dev/7c654734-df14-4b7c-e5a7-bf68f224c1be%40siemens.com.
