MarvellEmbeddedProcessors / atf-marvell

BSD 3-Clause "New" or "Revised" License
24 stars 24 forks source link

Incorrect calculation of amb_memory_amp size #7

Closed berolinux closed 6 years ago

berolinux commented 6 years ago

When trying to build atf-marvell with gcc 8, it errors out saying

plat/marvell/a8k/a80x0_mcbin/board/marvell_plat_config.c: In function ‘marvell_get_amb_memory_map’: plat/marvell/a8k/a80x0_mcbin/board/marvell_plat_config.c:92:33: error: division ‘sizeof (struct amb_win ) / sizeof (struct amb_win)’ does not compute the number of array elements [-Werror=sizeof-pointer-div] size = sizeof(amb_memory_map)/sizeof(struct amb_win); ^ plat/marvell/a8k/a80x0_mcbin/board/marvell_plat_config.c:79:17: note: first ‘sizeof’ operand was declared here struct amb_win *amb_memory_map; ^~~~~~ cc1: all warnings being treated as errors

This wasn't detected by earlier versions of gcc, but it looks like it is a genuine problem and *size simply got an incorrect value with earlier gcc -- the compiler can't know the size of the amb_memory_map array (which it sees as just an uninitialized pointer) in this translation unit.

berolinux commented 6 years ago

This was fixed in commit 15015079206a0373ac81d09626d92618d5969724