71 lines
2.9 KiB
Diff
71 lines
2.9 KiB
Diff
|
From 139d725cb2b293443e7b0db263401b588373a7cb Mon Sep 17 00:00:00 2001
|
||
|
From: Daan De Meyer <daan.j.demeyer@gmail.com>
|
||
|
Date: Mon, 30 Jan 2023 21:15:12 +0100
|
||
|
Subject: [PATCH] vmm: Add more const
|
||
|
|
||
|
SMBIOS tables are immutable, so let's access it via const pointers
|
||
|
where possible.
|
||
|
|
||
|
(cherry picked from commit 761f62fe98cab82a3742bdae49f79626ede2ceaf)
|
||
|
|
||
|
Related: RHEL-16952
|
||
|
---
|
||
|
src/boot/efi/vmm.c | 14 +++++++-------
|
||
|
1 file changed, 7 insertions(+), 7 deletions(-)
|
||
|
|
||
|
diff --git a/src/boot/efi/vmm.c b/src/boot/efi/vmm.c
|
||
|
index 6bd440f032..6b684e1bf4 100644
|
||
|
--- a/src/boot/efi/vmm.c
|
||
|
+++ b/src/boot/efi/vmm.c
|
||
|
@@ -201,17 +201,17 @@ typedef struct {
|
||
|
uint8_t bios_characteristics_ext[2];
|
||
|
} _packed_ SmbiosTableType0;
|
||
|
|
||
|
-static void *find_smbios_configuration_table(uint64_t *ret_size) {
|
||
|
+static const void *find_smbios_configuration_table(uint64_t *ret_size) {
|
||
|
assert(ret_size);
|
||
|
|
||
|
- Smbios3EntryPoint *entry3 = find_configuration_table(MAKE_GUID_PTR(SMBIOS3_TABLE));
|
||
|
+ const Smbios3EntryPoint *entry3 = find_configuration_table(MAKE_GUID_PTR(SMBIOS3_TABLE));
|
||
|
if (entry3 && memcmp(entry3->anchor_string, "_SM3_", 5) == 0 &&
|
||
|
entry3->entry_point_length <= sizeof(*entry3)) {
|
||
|
*ret_size = entry3->table_maximum_size;
|
||
|
return PHYSICAL_ADDRESS_TO_POINTER(entry3->table_address);
|
||
|
}
|
||
|
|
||
|
- SmbiosEntryPoint *entry = find_configuration_table(MAKE_GUID_PTR(SMBIOS_TABLE));
|
||
|
+ const SmbiosEntryPoint *entry = find_configuration_table(MAKE_GUID_PTR(SMBIOS_TABLE));
|
||
|
if (entry && memcmp(entry->anchor_string, "_SM_", 4) == 0 &&
|
||
|
entry->entry_point_length <= sizeof(*entry)) {
|
||
|
*ret_size = entry->table_length;
|
||
|
@@ -221,9 +221,9 @@ static void *find_smbios_configuration_table(uint64_t *ret_size) {
|
||
|
return NULL;
|
||
|
}
|
||
|
|
||
|
-static SmbiosHeader *get_smbios_table(uint8_t type) {
|
||
|
+static const SmbiosHeader *get_smbios_table(uint8_t type) {
|
||
|
uint64_t size = 0;
|
||
|
- uint8_t *p = find_smbios_configuration_table(&size);
|
||
|
+ const uint8_t *p = find_smbios_configuration_table(&size);
|
||
|
if (!p)
|
||
|
return false;
|
||
|
|
||
|
@@ -231,7 +231,7 @@ static SmbiosHeader *get_smbios_table(uint8_t type) {
|
||
|
if (size < sizeof(SmbiosHeader))
|
||
|
return NULL;
|
||
|
|
||
|
- SmbiosHeader *header = (SmbiosHeader *) p;
|
||
|
+ const SmbiosHeader *header = (const SmbiosHeader *) p;
|
||
|
|
||
|
/* End of table. */
|
||
|
if (header->type == 127)
|
||
|
@@ -273,7 +273,7 @@ static SmbiosHeader *get_smbios_table(uint8_t type) {
|
||
|
|
||
|
static bool smbios_in_hypervisor(void) {
|
||
|
/* Look up BIOS Information (Type 0). */
|
||
|
- SmbiosTableType0 *type0 = (SmbiosTableType0 *) get_smbios_table(0);
|
||
|
+ const SmbiosTableType0 *type0 = (const SmbiosTableType0 *) get_smbios_table(0);
|
||
|
if (!type0 || type0->header.length < sizeof(SmbiosTableType0))
|
||
|
return false;
|
||
|
|