Skip to content

Commit 58dcd82

Browse files
committed
x86/boot/e820: Standardize e820 table index variable types under 'u32'
So we have 'idx' types of 'int' and 'unsigned int', and sometimes we assign 'u32' fields such as e820_table::nr_entries to these 'int' values. While there's no real risk of overflow with these tables, make it all cleaner by standardizing on a single type: u32. This also happens to shrink the code a bit: text data bss dec hex filename 7745 44072 0 51817 ca69 e820.o.before 7613 44072 0 51685 c9e5 e820.o.after Signed-off-by: Ingo Molnar <mingo@kernel.org> Cc: H . Peter Anvin <hpa@zytor.com> Cc: Andy Shevchenko <andy@kernel.org> Cc: Arnd Bergmann <arnd@kernel.org> Cc: David Woodhouse <dwmw@amazon.co.uk> Cc: Juergen Gross <jgross@suse.com> Cc: Kees Cook <keescook@chromium.org> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Mike Rapoport <rppt@kernel.org> Cc: Paul Menzel <pmenzel@molgen.mpg.de> Cc: Peter Zijlstra <peterz@infradead.org> Link: https://patch.msgid.link/20250515120549.2820541-19-mingo@kernel.org
1 parent dc043d6 commit 58dcd82

1 file changed

Lines changed: 12 additions & 12 deletions

File tree

arch/x86/kernel/e820.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ EXPORT_SYMBOL(pci_mem_start);
7676
static bool _e820__mapped_any(struct e820_table *table,
7777
u64 start, u64 end, enum e820_type type)
7878
{
79-
int idx;
79+
u32 idx;
8080

8181
for (idx = 0; idx < table->nr_entries; idx++) {
8282
struct e820_entry *entry = &table->entries[idx];
@@ -111,7 +111,7 @@ EXPORT_SYMBOL_GPL(e820__mapped_any);
111111
static struct e820_entry *__e820__mapped_all(u64 start, u64 end,
112112
enum e820_type type)
113113
{
114-
int idx;
114+
u32 idx;
115115

116116
for (idx = 0; idx < e820_table->nr_entries; idx++) {
117117
struct e820_entry *entry = &e820_table->entries[idx];
@@ -164,7 +164,7 @@ int e820__get_entry_type(u64 start, u64 end)
164164
*/
165165
static void __init __e820__range_add(struct e820_table *table, u64 start, u64 size, enum e820_type type)
166166
{
167-
int idx = table->nr_entries;
167+
u32 idx = table->nr_entries;
168168

169169
if (idx >= ARRAY_SIZE(table->entries)) {
170170
pr_err("too many E820 table entries; ignoring [mem %#010llx-%#010llx]\n",
@@ -202,7 +202,7 @@ static void __init e820_print_type(enum e820_type type)
202202
static void __init e820__print_table(const char *who)
203203
{
204204
u64 range_end_prev = 0;
205-
int idx;
205+
u32 idx;
206206

207207
for (idx = 0; idx < e820_table->nr_entries; idx++) {
208208
struct e820_entry *entry = e820_table->entries + idx;
@@ -482,7 +482,7 @@ static u64 __init
482482
__e820__range_update(struct e820_table *table, u64 start, u64 size, enum e820_type old_type, enum e820_type new_type)
483483
{
484484
u64 end;
485-
unsigned int idx;
485+
u32 idx;
486486
u64 real_updated_size = 0;
487487

488488
BUG_ON(old_type == new_type);
@@ -560,7 +560,7 @@ u64 __init e820__range_update_table(struct e820_table *t, u64 start, u64 size,
560560
/* Remove a range of memory from the E820 table: */
561561
u64 __init e820__range_remove(u64 start, u64 size, enum e820_type old_type, bool check_type)
562562
{
563-
int idx;
563+
u32 idx;
564564
u64 end;
565565
u64 real_removed_size = 0;
566566

@@ -772,7 +772,7 @@ void __init e820__memory_setup_extended(u64 phys_addr, u32 data_len)
772772
*/
773773
void __init e820__register_nosave_regions(unsigned long limit_pfn)
774774
{
775-
int idx;
775+
u32 idx;
776776
u64 last_addr = 0;
777777

778778
for (idx = 0; idx < e820_table->nr_entries; idx++) {
@@ -797,7 +797,7 @@ void __init e820__register_nosave_regions(unsigned long limit_pfn)
797797
*/
798798
static int __init e820__register_nvs_regions(void)
799799
{
800-
int idx;
800+
u32 idx;
801801

802802
for (idx = 0; idx < e820_table->nr_entries; idx++) {
803803
struct e820_entry *entry = &e820_table->entries[idx];
@@ -848,7 +848,7 @@ u64 __init e820__memblock_alloc_reserved(u64 size, u64 align)
848848
*/
849849
static unsigned long __init e820__end_ram_pfn(unsigned long limit_pfn)
850850
{
851-
int idx;
851+
u32 idx;
852852
unsigned long last_pfn = 0;
853853
unsigned long max_arch_pfn = MAX_ARCH_PFN;
854854

@@ -1103,7 +1103,7 @@ static bool __init e820_device_region(enum e820_type type, struct resource *res)
11031103
*/
11041104
void __init e820__reserve_resources(void)
11051105
{
1106-
int idx;
1106+
u32 idx;
11071107
struct resource *res;
11081108
u64 end;
11091109

@@ -1168,7 +1168,7 @@ static unsigned long __init ram_alignment(resource_size_t pos)
11681168

11691169
void __init e820__reserve_resources_late(void)
11701170
{
1171-
int idx;
1171+
u32 idx;
11721172
struct resource *res;
11731173

11741174
/*
@@ -1272,7 +1272,7 @@ void __init e820__memory_setup(void)
12721272

12731273
void __init e820__memblock_setup(void)
12741274
{
1275-
int idx;
1275+
u32 idx;
12761276
u64 end;
12771277

12781278
#ifdef CONFIG_MEMORY_HOTPLUG

0 commit comments

Comments
 (0)