vmm: Add more const

SMBIOS tables are immutable, so let's access it via const pointers
where possible.
This commit is contained in:
Daan De Meyer
2023-02-23 09:50:18 +01:00
parent e71f0f63da
commit 761f62fe98
+7 -7
View File
@@ -204,17 +204,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;
@@ -224,9 +224,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;
@@ -234,7 +234,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)
@@ -276,7 +276,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;