x86: kaslr: select memory region from e820 maps
As a logic simplification, the following gets rid of one variable that's simply not needed. (And adds a "static" declaration that seems to be appropriate):
static bool largest_ram_region(unsigned long *start, unsigned long *size)
{
int i;
*size = 0;
for (i = 0; i < real_mode->e820_entries; i++) {
struct e820entry *entry = &real_mode->e820_map[i];
if (entry->type != E820_RAM)
continue;
if (entry->size > *size) {
*size = entry->size;
*start = entry->addr;
}
}
return *size != 0;
}but I might instead do it as:
struct e820_entry const *largest_ram_region()
{
struct e820_entry const *rc = NULL;
unsigned long size = 0;
int i;
for (i = 0; i < real_mode->e820_entries; i++) {
struct e820entry const *entry = &real_mode->e820_map[i];
if (entry->type == E820_RAM && entry->size > size) {
size = entry->size;
rc = entry;
}
}
return rc;
}... with appropriate adjustments to the caller. Anyway, your choice.