RTEMS | uC5282 bspstart.c warnings for questionable code (#5242)
Joel Sherrill (@joel)
gitlab at rtems.org
Fri Apr 25 15:23:55 UTC 2025
Joel Sherrill created an issue: https://gitlab.rtems.org/rtems/rtos/rtems/-/issues/5242
## Summary
The uC5282 BSP's bspstart.c file has a handful of warnings that are from using a subscript that is outside the array bounds. This is part of the output compiling with GCC 14.
```
../../../bsps/m68k/uC5282/start/bspstart.c: In function 'bsp_start':
../../../bsps/m68k/uC5282/start/bspstart.c:183:13: warning: array subscript 0 is outside array bounds of 'void (*[0])(int)' [-Warray-bounds=]
183 | if ( 0 == *((void (**)(int))((32+2) * 4)) )
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: note: source object is likely at address zero
../../../bsps/m68k/uC5282/start/bspstart.c:184:5: warning: array subscript 0 is outside array bounds of 'void (*[0])(int)' [-Warray-bounds=]
184 | *((void (**)(int))((32+2) * 4)) = bsp_fake_syscall;
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: note: source object is likely at address zero
../../../bsps/m68k/uC5282/start/bspstart.c: In function 'handler':
../../../bsps/m68k/uC5282/start/bspstart.c:109:9: warning: array subscript -1 is outside array bounds of 'int[1]' [-Warray-bounds=]
109 | int info = p[-1];
| ^~~~
../../../bsps/m68k/uC5282/start/bspstart.c:100:25: note: at offset -4 into object 'pc' of size 4
100 | static void handler(int pc)
```
The warnings around line 109 are from taking the address of the first parameter and negatively indexing from that to get information from the stack. It is using negative array indices in some places. This may be able to be resolved by defining a structure that maps onto that area of the stack and calculating the starting address of that.
The warnings at line 183/184 can possibly be resolved by using a type instead of those ugly casts. The function _CPU_ISR_install_raw_handler() in cpukit/score/cpu/m68k/cpu.c seems to include code to do this without a cast. That should be able to be used as a model for the fix.
## Steps to reproduce
### Pre-set options
--
View it on GitLab: https://gitlab.rtems.org/rtems/rtos/rtems/-/issues/5242
You're receiving this email because of your account on gitlab.rtems.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/bugs/attachments/20250425/5c2835c6/attachment.htm>
More information about the bugs
mailing list