chibios/os/hal/platforms/STM32/OTGv1/usb_lld.c: In function 'usb_lld_pump': chibios/os/hal/platforms/STM32/OTGv1/usb_lld.c:769:1: error: no return statement in function returning non-void [-Werror=return-type] } ^ cc1.exe: all warnings being treated as errors make: *** [build/obj/usb_lld.o] Error 1
that's because 'return 0;' was removed in 2.6.7 comparing with 2.6.6. That would be the only place where it complaints about no-return so I guess it should be?
Index: hal/platforms/STM32/OTGv1/usb_lld.c =================================================================== --- hal/platforms/STM32/OTGv1/usb_lld.c (revision 6925) +++ hal/platforms/STM32/OTGv1/usb_lld.c (working copy) @@ -766,6 +766,8 @@ } chSysLock(); } + // we are never here but GCC cannot figure this out + return 0; }
There are three compilers to consider: GCC complains because there is no "return" statement even if it is obvious it cannot be reached. IAR and Keil complain about an unreachable "return" statement.
2 vs 1
This is why you see that warning in all demos, in my opinion GCC is wrong in this case. The solution would be to make threads void-returning functions but I am not sure it would be a good idea.
Another approach to disable the bogus warning for GCC is to disable the warning just for the problem function.
For example, my usb_lld.c is modified as follows:
#if defined __GNUC__ #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wreturn-type" #endif static msg_t usb_lld_pump(void *p) { ... } #if defined __GNUC__ #pragma GCC diagnostic pop #endif
It would be nice to remove the bogus compiler warnings; with too many bogus warnings, valid warnings get lost in the noise; builds should be clean without warnings.