PhysicalMemory: make sure to detect all memory devices

This commit is contained in:
Carter Li
2024-07-31 11:13:04 +08:00
parent cf0d1cf294
commit bd5012edc8
3 changed files with 15 additions and 3 deletions
@@ -23,6 +23,12 @@ static inline const char* getVendorString(unsigned vendorId)
void FFPhysicalMemoryUpdateVendorString(FFPhysicalMemoryResult* device)
{
if (ffStrbufEqualS(&device->vendor, "Unknown"))
{
ffStrbufClear(&device->vendor);
return;
}
char vendorIdStr[5];
if (ffStrbufStartsWithS(&device->vendor, "0x"))
{
@@ -75,10 +75,10 @@ const char* ffDetectPhysicalMemory(FFlist* result)
if (!data)
return "Memory device is not found in SMBIOS data";
for (; data->Header.Type == FF_SMBIOS_TYPE_MEMORY_DEVICE;
data = (const FFSmbiosMemoryDevice*) ffSmbiosNextEntry(&data->Header))
for (; data->Header.Type < FF_SMBIOS_TYPE_END_OF_TABLE;
data = (const FFSmbiosMemoryDevice*) ffSmbiosNextEntry(&data->Header))
{
if (data->Size == 0) continue;
if (data->Header.Type != FF_SMBIOS_TYPE_MEMORY_DEVICE || data->Size == 0) continue;
const char* strings = (const char*) data + data->Header.Length;
@@ -20,6 +20,12 @@ void ffPrintPhysicalMemory(FFPhysicalMemoryOptions* options)
return;
}
if (result.length == 0)
{
ffPrintError(FF_PHYSICALMEMORY_DISPLAY_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "No physical memory detected");
return;
}
FF_STRBUF_AUTO_DESTROY prettySize = ffStrbufCreate();
uint32_t i = 0;