svn commit: r338533 - head/sbin/sysctl
Konstantin Belousov
kib at FreeBSD.org
Sat Sep 8 18:57:06 UTC 2018
Author: kib
Date: Sat Sep 8 18:57:05 2018
New Revision: 338533
URL: https://svnweb.freebsd.org/changeset/base/338533
Log:
Improve handling of the EFI map types[] array.
Use nitems(), do not assume EFI_MD_TYPE_ contiguous allocation, in
particular, switch to use designated array initializers.
Reviewed by: jhb (previous version)
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Approved by: re (gjb)
Modified:
head/sbin/sysctl/sysctl.c
Modified: head/sbin/sysctl/sysctl.c
==============================================================================
--- head/sbin/sysctl/sysctl.c Sat Sep 8 08:52:52 2018 (r338532)
+++ head/sbin/sysctl/sysctl.c Sat Sep 8 18:57:05 2018 (r338533)
@@ -690,22 +690,22 @@ S_efi_map(size_t l2, void *p)
size_t efisz;
int ndesc, i;
- static const char *types[] = {
- "Reserved",
- "LoaderCode",
- "LoaderData",
- "BootServicesCode",
- "BootServicesData",
- "RuntimeServicesCode",
- "RuntimeServicesData",
- "ConventionalMemory",
- "UnusableMemory",
- "ACPIReclaimMemory",
- "ACPIMemoryNVS",
- "MemoryMappedIO",
- "MemoryMappedIOPortSpace",
- "PalCode",
- "PersistentMemory"
+ static const char * const types[] = {
+ [EFI_MD_TYPE_NULL] = "Reserved",
+ [EFI_MD_TYPE_CODE] = "LoaderCode",
+ [EFI_MD_TYPE_DATA] = "LoaderData",
+ [EFI_MD_TYPE_BS_CODE] = "BootServicesCode",
+ [EFI_MD_TYPE_BS_DATA] = "BootServicesData",
+ [EFI_MD_TYPE_RT_CODE] = "RuntimeServicesCode",
+ [EFI_MD_TYPE_RT_DATA] = "RuntimeServicesData",
+ [EFI_MD_TYPE_FREE] = "ConventionalMemory",
+ [EFI_MD_TYPE_BAD] = "UnusableMemory",
+ [EFI_MD_TYPE_RECLAIM] = "ACPIReclaimMemory",
+ [EFI_MD_TYPE_FIRMWARE] = "ACPIMemoryNVS",
+ [EFI_MD_TYPE_IOMEM] = "MemoryMappedIO",
+ [EFI_MD_TYPE_IOPORT] = "MemoryMappedIOPortSpace",
+ [EFI_MD_TYPE_PALCODE] = "PalCode",
+ [EFI_MD_TYPE_PERSISTENT] = "PersistentMemory",
};
/*
@@ -734,9 +734,10 @@ S_efi_map(size_t l2, void *p)
for (i = 0; i < ndesc; i++,
map = efi_next_descriptor(map, efihdr->descriptor_size)) {
- if (map->md_type <= EFI_MD_TYPE_PERSISTENT)
+ type = NULL;
+ if (map->md_type < nitems(types))
type = types[map->md_type];
- else
+ if (type == NULL)
type = "<INVALID>";
printf("\n%23s %012jx %12p %08jx ", type,
(uintmax_t)map->md_phys, map->md_virt,
More information about the svn-src-head
mailing list