[tip:x86/boot] x86/boot/e820: Clean up and standardize sizeof() uses

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Commit-ID:  d88961b5d4366c33d35d9ad309791ed9e4424f6c
Gitweb:     http://git.kernel.org/tip/d88961b5d4366c33d35d9ad309791ed9e4424f6c
Author:     Ingo Molnar <mingo@xxxxxxxxxx>
AuthorDate: Sat, 28 Jan 2017 17:48:08 +0100
Committer:  Ingo Molnar <mingo@xxxxxxxxxx>
CommitDate: Sat, 28 Jan 2017 22:55:23 +0100

x86/boot/e820: Clean up and standardize sizeof() uses

There's various sizeof() uses in e820.c - standardize on the shortest
and least error prone one, along the pattern of:

-	memset(entry, 0, sizeof(struct e820_entry));
+	memset(entry, 0, sizeof(*entry));

... because with this pattern in most cases it's immediately clear that
we have used the right type - and the pattern is robust against changing
the type as well.

No change in functionality.

Cc: Alex Thorlton <athorlton@xxxxxxx>
Cc: Andy Lutomirski <luto@xxxxxxxxxx>
Cc: Borislav Petkov <bp@xxxxxxxxx>
Cc: Brian Gerst <brgerst@xxxxxxxxx>
Cc: Dan Williams <dan.j.williams@xxxxxxxxx>
Cc: Denys Vlasenko <dvlasenk@xxxxxxxxxx>
Cc: H. Peter Anvin <hpa@xxxxxxxxx>
Cc: Huang, Ying <ying.huang@xxxxxxxxx>
Cc: Josh Poimboeuf <jpoimboe@xxxxxxxxxx>
Cc: Juergen Gross <jgross@xxxxxxxx>
Cc: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx>
Cc: Paul Jackson <pj@xxxxxxx>
Cc: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
Cc: Rafael J. Wysocki <rjw@xxxxxxx>
Cc: Tejun Heo <tj@xxxxxxxxxx>
Cc: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
Cc: Wei Yang <richard.weiyang@xxxxxxxxx>
Cc: Yinghai Lu <yinghai@xxxxxxxxxx>
Cc: linux-kernel@xxxxxxxxxxxxxxx
Signed-off-by: Ingo Molnar <mingo@xxxxxxxxxx>
---
 arch/x86/kernel/e820.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c
index 055ac24..da69add 100644
--- a/arch/x86/kernel/e820.c
+++ b/arch/x86/kernel/e820.c
@@ -306,7 +306,7 @@ int __init e820__update_table(struct e820_entry *biosmap, int max_nr_map, u32 *p
 	chg_nr = chgidx;
 
 	/* Sort change-point list by memory addresses (low -> high): */
-	sort(change_point, chg_nr, sizeof *change_point, cpcompare, NULL);
+	sort(change_point, chg_nr, sizeof(*change_point), cpcompare, NULL);
 
 	/* Create a new BIOS memory map, removing overlaps: */
 	overlap_entries = 0;	 /* Number of entries in the overlap table */
@@ -362,7 +362,7 @@ int __init e820__update_table(struct e820_entry *biosmap, int max_nr_map, u32 *p
 	new_nr = new_bios_entry;
 
 	/* Copy new BIOS mapping into the original location: */
-	memcpy(biosmap, new_bios, new_nr*sizeof(struct e820_entry));
+	memcpy(biosmap, new_bios, new_nr*sizeof(*biosmap));
 	*pnr_map = new_nr;
 
 	return 0;
@@ -513,7 +513,7 @@ u64 __init e820__range_remove(u64 start, u64 size, enum e820_type old_type, int
 		/* Completely covered? */
 		if (entry->addr >= start && entry_end <= end) {
 			real_removed_size += entry->size;
-			memset(entry, 0, sizeof(struct e820_entry));
+			memset(entry, 0, sizeof(*entry));
 			continue;
 		}
 
@@ -672,7 +672,7 @@ void __init e820__memory_setup_extended(u64 phys_addr, u32 data_len)
 	struct setup_data *sdata;
 
 	sdata = early_memremap(phys_addr, data_len);
-	entries = sdata->len / sizeof(struct e820_entry);
+	entries = sdata->len / sizeof(*extmap);
 	extmap = (struct e820_entry *)(sdata->data);
 
 	__append_e820_table(extmap, entries);
@@ -932,7 +932,7 @@ void __init e820_reserve_setup_data(void)
 	}
 
 	e820__update_table(e820_table->entries, ARRAY_SIZE(e820_table->entries), &e820_table->nr_entries);
-	memcpy(e820_table_firmware, e820_table, sizeof(struct e820_table));
+	memcpy(e820_table_firmware, e820_table, sizeof(*e820_table_firmware));
 	printk(KERN_INFO "extended physical RAM map:\n");
 	e820__print_table("reserve setup_data");
 }
@@ -1169,7 +1169,7 @@ void __init e820__memory_setup(void)
 
 	who = x86_init.resources.memory_setup();
 
-	memcpy(e820_table_firmware, e820_table, sizeof(struct e820_table));
+	memcpy(e820_table_firmware, e820_table, sizeof(*e820_table_firmware));
 
 	pr_info("e820: BIOS-provided physical RAM map:\n");
 	e820__print_table(who);
--
To unsubscribe from this list: send the line "unsubscribe linux-tip-commits" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Stable Commits]     [Linux Stable Kernel]     [Linux Kernel]     [Linux USB Devel]     [Linux Video &Media]     [Linux Audio Users]     [Yosemite News]     [Linux SCSI]

  Powered by Linux