Make: enable -Werror -Wall -Wextra by default#7919
Conversation
|
also tracked issues in #7875 need to be fixed for this. |
|
While most of the fix commits are trivial, some are not, which will make reviewing difficult. I suggest you make this PR only enable the extra warnings, and then open smaller PR's fixing the actual compile issues. You could group them (e.g., all "unused parameter" fixes, then all "signed compare" ...). |
|
@kaspar030 you're right, on first sight I thought: just a few fixes, make it one PR. But then the list got longer and longer and longer ... as always, will split in groups as suggested. |
cladmi
left a comment
There was a problem hiding this comment.
I just did a read through code review, not tested.
Could be a good idea to add a "RM ME later" commit that makes WPEDANTIC by default to see murdock output.
cpu/cc2538/include/cpu_conf.h
Outdated
| #include "cpu_conf_common.h" | ||
| /* store compiler switches */ | ||
| #pragma GCC diagnostic push | ||
| #pragma GCC diagnostic ignored "-Wpedantic" |
There was a problem hiding this comment.
For this warning ignoring, I would prefer to see why its disabled than "store compiler switches".
There was a problem hiding this comment.
yes right, here and below its mostly to exclude vendor headers from being checked with pedantic on - because we don't want to change or fix them but rather use the originals and also update them from time to time
cpu/cc26x0/include/cpu_conf.h
Outdated
|
|
||
| /* store compiler switches */ | ||
| #pragma GCC diagnostic push | ||
| #pragma GCC diagnostic ignored "-Wpedantic" |
There was a problem hiding this comment.
Same here, comment why pedantic is disabled.
cpu/k22f/include/cpu_conf.h
Outdated
|
|
||
| /* store compiler switches */ | ||
| #pragma GCC diagnostic push | ||
| #pragma GCC diagnostic ignored "-Wpedantic" |
There was a problem hiding this comment.
Same here, comment why pedantic is disabled.
cpu/k60/include/cpu_conf.h
Outdated
| #ifndef CPU_CONF_H | ||
| #define CPU_CONF_H | ||
|
|
||
| /* store compiler switches */ |
There was a problem hiding this comment.
Same here, comment why pedantic is disabled.
cpu/k64f/include/cpu_conf.h
Outdated
| #ifndef CPU_CONF_H | ||
| #define CPU_CONF_H | ||
|
|
||
| /* store compiler switches */ |
There was a problem hiding this comment.
Same here, comment why pedantic is disabled.
cpu/kw2xd/include/cpu_conf.h
Outdated
| #ifndef CPU_CONF_H | ||
| #define CPU_CONF_H | ||
|
|
||
| /* store compiler switches */ |
There was a problem hiding this comment.
Same here, comment why pedantic is disabled.
| */ | ||
| int timer_init(tim_t dev, unsigned long freq, timer_cb_t cb, void *arg) | ||
| { | ||
| /* at the moment, the timer can only run at 1MHz */ |
There was a problem hiding this comment.
This is not related to -Wall -Wextra, or is it ?
There was a problem hiding this comment.
This is not related to -Wall -Wextra, or is it ?
Ping @smlng?
There was a problem hiding this comment.
mhm, IIRC copy pasted from samd21/periph/timer.c, but don't know why/how it slipped in here. Shall I remove?
| if ((channel < AT86RF2XX_MIN_CHANNEL) || | ||
| (channel > AT86RF2XX_MAX_CHANNEL) || | ||
| if ((channel > AT86RF2XX_MAX_CHANNEL) || | ||
| #if AT86RF2XX_MIN_CHANNEL /* is zero for sub-GHz */ |
There was a problem hiding this comment.
Maybe duplicate the if lines for readability here, like in _netdev.c
There was a problem hiding this comment.
Maybe duplicate the if lines for readability here, like in _netdev.c
Ping @smlng?
fb79a83 to
0ec65b2
Compare
|
separated into fixes into groups as suggested by @kaspar030, this PR now requires #7993, #7994, #7995, and other before merge. |
0ec65b2 to
7539e0f
Compare
|
Please let us know when you finished the sub-PRs so we can review them. |
|
@cladmi yep, will do - forgot to mark |
7539e0f to
ae063ea
Compare
sure, though I like all to have all green 😉 |
|
When this get's merged today, you should write a reminder to the maintainers (and maybe even devel) mailing list that all builds on Murdock should be rebuild before merging ;-). Otherwise older PRs could re-introduce new bugs. |
|
murdock looks good, may I squash? |
|
Yes, please! |
d091574 to
462373a
Compare
|
squashed |
|
@cladmi can you have another look, so we can merge this soonish! Merci! |
|
ping! This might be worth two (or more) ACKs before merge?! |
|
(The rebuild rule should be applied here as well, before hitting the green button, btw ;-)) |
pkg, nordic_softdevice_ble: disable CFLAGS to omit compiler error
sys, pm_layered: fix casting nonscalar to the same type
cpu, stm32_common: fix type-limits, remove always true assert
cpu, stm32f4: fix pointer arithmetic in periph/i2c
drivers, at86rf2xx: fix type-limits where condition always true
saul, gpio: fix if no gpio configured for saul
cpu, saml21: add frequency check to periph/timer
driver, cc110x: fix unused param and type-limts errors
boards, wsn430-common: fix old-style-declaration
make: fix old style definition
drivers, sdcard_spi: fix old style typedef
driver, at30tse: remove unnecessary check
driver, nrf24: fix type-limit
driver, pn532: change buffer from char to uint8_t
tests/driver_sdcard: fix type limits
boards, feather-m0: add missing field inits
driver, tcs37727: fix type limits
pkg, emb6: disable some compiler warnings
tests/emb6: disable some compiler warings
pkg, openthread: fix sign compare and unused params
tests/trickle: fix struct init
tests/pthread_cooperation: fix type limits
board, mips-malta: remove feature periph_uart
shell: fix var size for netif command
gnrc, netif: fix sign-compare
gnrc, nib: fix sign-compare
shell: fix output in netif command
posix: fix type-limits in pthread_cond
462373a to
cbc23b5
Compare
drivers/nrf24l01p/nrf24l01p.c
Outdated
| } | ||
|
|
||
| if (width < 0) { | ||
| if (width == 0) { |
There was a problem hiding this comment.
width == 0 was not an error before.
There was a problem hiding this comment.
? width < 0 also matches width == 0 and as width is unsigned its the same
There was a problem hiding this comment.
No... width < 0 is not equivalent to width == 0, even if unsigned... An unsigned can be 0, and width < 0 would still be false.
There was a problem hiding this comment.
you're right, its not the same. However, width is unsigned so < 0 makes no sense, further it also makes no sense to set payload length 0, too. So the check is still valid (IMHO).
There was a problem hiding this comment.
But it changes the meaning completely now (let's not even talk about the API change). If 0 wasn't an error case before, you made it one now.
There was a problem hiding this comment.
well then the checked can be removed completely, if that's the (intermediate) solution - leaving a side that width = 0 should be wrong anyway.
There was a problem hiding this comment.
Since this PR is not about changing any functional errors I would prefer the intermediate solution and a fix as a follow-up.
| */ | ||
| int timer_init(tim_t dev, unsigned long freq, timer_cb_t cb, void *arg) | ||
| { | ||
| /* at the moment, the timer can only run at 1MHz */ |
| if ((channel < AT86RF2XX_MIN_CHANNEL) || | ||
| (channel > AT86RF2XX_MAX_CHANNEL) || | ||
| if ((channel > AT86RF2XX_MAX_CHANNEL) || | ||
| #if AT86RF2XX_MIN_CHANNEL /* is zero for sub-GHz */ |
tests/trickle/main.c
Outdated
|
|
||
| static trickle_t trickle = { .callback.func = &callback, | ||
| .callback.args = NULL }; | ||
| static trickle_t trickle; |
There was a problem hiding this comment.
What was the problem with this one ?
There was a problem hiding this comment.
the way of init the struct caused an error.
There was a problem hiding this comment.
so separated definition and init
There was a problem hiding this comment.
maybe use
static trickle_t trickle = { .callback = { .func = &callback,
.args = NULL } };instead? It doesn't change the behavior and is the more correct version.
There was a problem hiding this comment.
For native, iotlab-m3, samr21-xpro I get no error with the first version.
What was the error ? the commit message does not help me "tests/trickle: fix struct init"
There was a problem hiding this comment.
Error was reported by clang on macOS, which is often more pedantic than gcc
There was a problem hiding this comment.
mhm, can't reproduce right now - maybe it was reported by Murdock on some other platform (too). At least the old init version didn't work, @miri64 solution looks okay to me, too.
|
Only need to squash and wait for murdock. |
58d167c to
57c5c9b
Compare
|
squashed |
This was made visible by RIOT-OS#7919. Broke build on GCC 7.2. Probably a bug.
This was made visible by RIOT-OS#7919. Broke build on GCC 7.2. Probably a bug.
This picks up the idea of #1121 (which isn't mergeable anymore, because of considerable changes since then) to enable more compiler warnings and make them errors to fail. This PR also ships several fixes to make things work.
It also provides an option to turn on
-Wpedantictoo, however, that would require even more work and also some agreement (e.g., usage of gcc extensions, see #7918).may need #7860 and other existing PR that solve open issues.