Page 1 of 1
2.6.7 usb_lld_pump: no return statement
Posted: Tue Feb 17, 2015 5:05 pm
by russian
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?
Code: Select all
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;
}
#if STM32_USB_USE_OTG1 || defined(__DOXYGEN__)
Re: 2.6.7 usb_lld_pump: no return statement
Posted: Tue Feb 17, 2015 5:18 pm
by Giovanni
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.
Giovanni
Re: 2.6.7 usb_lld_pump: no return statement
Posted: Tue Feb 17, 2015 5:23 pm
by russian
Oh, right - in fact I do have this issue with IAR with my own code. Because of that I do
#if defined __GNUC__
return 0;
#endif
Re: 2.6.7 usb_lld_pump: no return statement
Posted: Thu Apr 02, 2015 3:42 pm
by dalbert
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.
Re: 2.6.7 usb_lld_pump: no return statement
Posted: Thu Apr 02, 2015 3:53 pm
by Giovanni
Hi,
I am thinking to make thread functions return "void", this would fix the issue but also delay the release slightly.
There could also be other advantages, I am evaluating tradeoffs. This would happen in 3.0 anyway.
Giovanni
Re: 2.6.7 usb_lld_pump: no return statement
Posted: Fri Apr 03, 2015 1:52 pm
by Giovanni
I implemented threads returning void, this eliminates also the problem with the warning.
Giovanni