[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen stable-4.12] x86/e820: fix build with gcc9
commit eb905217d1ff51d6d2b3dbe8cdf618ef40ab2d77 Author: Jan Beulich <jbeulich@xxxxxxxx> AuthorDate: Fri May 3 10:43:13 2019 +0200 Commit: Jan Beulich <jbeulich@xxxxxxxx> CommitDate: Fri May 3 10:43:13 2019 +0200 x86/e820: fix build with gcc9 e820.c: In function â??clip_to_limitâ??: .../xen/include/asm/string.h:10:26: error: â??__builtin_memmoveâ?? offset [-16, -36] is out of the bounds [0, 20484] of object â??e820â?? with type â??struct e820mapâ?? [-Werror=array-bounds] 10 | #define memmove(d, s, n) __builtin_memmove(d, s, n) | ^~~~~~~~~~~~~~~~~~~~~~~~~~ e820.c:404:13: note: in expansion of macro â??memmoveâ?? 404 | memmove(&e820.map[i], &e820.map[i+1], | ^~~~~~~ e820.c:36:16: note: â??e820â?? declared here 36 | struct e820map e820; | ^~~~ While I can't see where the negative offsets would come from, converting the loop index to unsigned type helps. Take the opportunity and also convert several other local variables and copy_e820_map()'s second parameter to unsigned int (and bool in one case). Reported-by: Charles Arnold <carnold@xxxxxxxx> Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx> Reviewed-by: Roger Pau Monné <roger.pau@xxxxxxxxxx> Reviewed-by: Wei Liu <wei.liu2@xxxxxxxxxx> Acked-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx> master commit: 22e2f8dddf5fbed885b5e4db3ffc9e1101be9ec0 master date: 2019-03-18 11:38:36 +0100 --- xen/arch/x86/e820.c | 32 ++++++++++++++------------------ 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/xen/arch/x86/e820.c b/xen/arch/x86/e820.c index 0c67ccd262..8e8a2c4e1b 100644 --- a/xen/arch/x86/e820.c +++ b/xen/arch/x86/e820.c @@ -44,7 +44,7 @@ struct e820map __initdata e820_raw; */ int __init e820_all_mapped(u64 start, u64 end, unsigned type) { - int i; + unsigned int i; for (i = 0; i < e820.nr_map; i++) { struct e820entry *ei = &e820.map[i]; @@ -73,9 +73,7 @@ int __init e820_all_mapped(u64 start, u64 end, unsigned type) static void __init add_memory_region(unsigned long long start, unsigned long long size, int type) { - int x; - - x = e820.nr_map; + unsigned int x = e820.nr_map; if (x == ARRAY_SIZE(e820.map)) { printk(KERN_ERR "Ooops! Too many entries in the memory map!\n"); @@ -140,11 +138,9 @@ int __init sanitize_e820_map(struct e820entry *biosmap, unsigned int *pnr_map) struct change_member *change_tmp; unsigned long current_type, last_type; unsigned long long last_addr; - int chgidx, still_changing; - int overlap_entries; - int new_bios_entry; - int old_nr, new_nr, chg_nr; - int i; + bool still_changing; + unsigned int i, chgidx, overlap_entries, new_bios_entry; + unsigned int old_nr, new_nr, chg_nr; /* Visually we're performing the following (1,2,3,4 = memory types)... @@ -211,9 +207,9 @@ int __init sanitize_e820_map(struct e820entry *biosmap, unsigned int *pnr_map) chg_nr = chgidx; /* true number of change-points */ /* sort change-point list by memory addresses (low -> high) */ - still_changing = 1; + still_changing = true; while (still_changing) { - still_changing = 0; + still_changing = false; for (i=1; i < chg_nr; i++) { /* if <current_addr> > <last_addr>, swap */ /* or, if current=<start_addr> & last=<end_addr>, swap */ @@ -226,7 +222,7 @@ int __init sanitize_e820_map(struct e820entry *biosmap, unsigned int *pnr_map) change_tmp = change_point[i]; change_point[i] = change_point[i-1]; change_point[i-1] = change_tmp; - still_changing=1; + still_changing = true; } } } @@ -304,9 +300,9 @@ int __init sanitize_e820_map(struct e820entry *biosmap, unsigned int *pnr_map) * thinkpad 560x, for example, does not cooperate with the memory * detection code.) */ -static int __init copy_e820_map(struct e820entry * biosmap, int nr_map) +static int __init copy_e820_map(struct e820entry * biosmap, unsigned int nr_map) { - /* Only one memory region (or negative)? Ignore it */ + /* Only one memory region? Ignore it */ if (nr_map < 2) return -1; @@ -345,7 +341,7 @@ static int __init copy_e820_map(struct e820entry * biosmap, int nr_map) */ static unsigned long __init find_max_pfn(void) { - int i; + unsigned int i; unsigned long max_pfn = 0; for (i = 0; i < e820.nr_map; i++) { @@ -366,7 +362,7 @@ static unsigned long __init find_max_pfn(void) static void __init clip_to_limit(uint64_t limit, char *warnmsg) { - int i; + unsigned int i; char _warnmsg[160]; uint64_t old_limit = 0; @@ -514,7 +510,7 @@ static void __init machine_specific_memory_setup(struct e820map *raw) { unsigned long mpt_limit, ro_mpt_limit; uint64_t top_of_ram, size; - int i; + unsigned int i; sanitize_e820_map(raw->map, &raw->nr_map); copy_e820_map(raw->map, raw->nr_map); @@ -604,7 +600,7 @@ int __init e820_change_range_type( uint32_t orig_type, uint32_t new_type) { uint64_t rs = 0, re = 0; - int i; + unsigned int i; for ( i = 0; i < e820->nr_map; i++ ) { -- generated by git-patchbot for /home/xen/git/xen.git#stable-4.12 _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |