Skip to content

Make: enable -Werror -Wall -Wextra by default#7919

Merged
cladmi merged 2 commits intoRIOT-OS:masterfrom
smlng:make/wpedantic
Nov 28, 2017
Merged

Make: enable -Werror -Wall -Wextra by default#7919
cladmi merged 2 commits intoRIOT-OS:masterfrom
smlng:make/wpedantic

Conversation

@smlng
Copy link
Copy Markdown
Member

@smlng smlng commented Oct 31, 2017

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 -Wpedantic too, 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.

@smlng smlng added Type: cleanup The issue proposes a clean-up / The PR cleans-up parts of the codebase / documentation Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation Area: build system Area: Build system labels Oct 31, 2017
@smlng smlng added State: WIP State: The PR is still work-in-progress and its code is not in its final presentable form yet CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR labels Oct 31, 2017
@smlng
Copy link
Copy Markdown
Member Author

smlng commented Oct 31, 2017

also tracked issues in #7875 need to be fixed for this.

@kaspar030
Copy link
Copy Markdown
Contributor

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" ...).

@smlng
Copy link
Copy Markdown
Member Author

smlng commented Nov 1, 2017

@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.

Copy link
Copy Markdown
Contributor

@cladmi cladmi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

#include "cpu_conf_common.h"
/* store compiler switches */
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wpedantic"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For this warning ignoring, I would prefer to see why its disabled than "store compiler switches".

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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


/* store compiler switches */
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wpedantic"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, comment why pedantic is disabled.


/* store compiler switches */
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wpedantic"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, comment why pedantic is disabled.

#ifndef CPU_CONF_H
#define CPU_CONF_H

/* store compiler switches */
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, comment why pedantic is disabled.

#ifndef CPU_CONF_H
#define CPU_CONF_H

/* store compiler switches */
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, comment why pedantic is disabled.

#ifndef CPU_CONF_H
#define CPU_CONF_H

/* store compiler switches */
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 */
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not related to -Wall -Wextra, or is it ?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not related to -Wall -Wextra, or is it ?

Ping @smlng?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mhm, IIRC copy pasted from samd21/periph/timer.c, but don't know why/how it slipped in here. Shall I remove?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't care it can stay.

if ((channel < AT86RF2XX_MIN_CHANNEL) ||
(channel > AT86RF2XX_MAX_CHANNEL) ||
if ((channel > AT86RF2XX_MAX_CHANNEL) ||
#if AT86RF2XX_MIN_CHANNEL /* is zero for sub-GHz */
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe duplicate the if lines for readability here, like in _netdev.c

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe duplicate the if lines for readability here, like in _netdev.c

Ping @smlng?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well, maybe not?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, its just style.

@smlng
Copy link
Copy Markdown
Member Author

smlng commented Nov 10, 2017

separated into fixes into groups as suggested by @kaspar030, this PR now requires #7993, #7994, #7995, and other before merge.

@smlng smlng added the State: waiting for other PR State: The PR requires another PR to be merged first label Nov 10, 2017
@smlng
Copy link
Copy Markdown
Member Author

smlng commented Nov 10, 2017

rebased onto #7993, #7994, #7995 -> they are now included here, to check with Murdock whats still missing,

@cladmi
Copy link
Copy Markdown
Contributor

cladmi commented Nov 10, 2017

Please let us know when you finished the sub-PRs so we can review them.

@smlng
Copy link
Copy Markdown
Member Author

smlng commented Nov 10, 2017

@cladmi yep, will do - forgot to mark it them WIP, sorry

@smlng
Copy link
Copy Markdown
Member Author

smlng commented Nov 28, 2017

we also could do that in a separate PR.

sure, though I like all to have all green 😉

@miri64
Copy link
Copy Markdown
Member

miri64 commented Nov 28, 2017

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.

@smlng
Copy link
Copy Markdown
Member Author

smlng commented Nov 28, 2017

murdock looks good, may I squash?

@miri64
Copy link
Copy Markdown
Member

miri64 commented Nov 28, 2017

Yes, please!

@smlng
Copy link
Copy Markdown
Member Author

smlng commented Nov 28, 2017

squashed

@smlng
Copy link
Copy Markdown
Member Author

smlng commented Nov 28, 2017

@cladmi can you have another look, so we can merge this soonish! Merci!

@smlng
Copy link
Copy Markdown
Member Author

smlng commented Nov 28, 2017

ping! This might be worth two (or more) ACKs before merge?!

@smlng smlng added the Community: Hack'n'ACK candidate This PR is a candidate for review and discussion during one of RIOT's monthly Hack'n'ACK parties label Nov 28, 2017
Copy link
Copy Markdown
Member

@miri64 miri64 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. I'm fine with this.

@miri64
Copy link
Copy Markdown
Member

miri64 commented Nov 28, 2017

(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
}

if (width < 0) {
if (width == 0) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

width == 0 was not an error before.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

? width < 0 also matches width == 0 and as width is unsigned its the same

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No... width < 0 is not equivalent to width == 0, even if unsigned... An unsigned can be 0, and width < 0 would still be false.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well then the checked can be removed completely, if that's the (intermediate) solution - leaving a side that width = 0 should be wrong anyway.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this PR is not about changing any functional errors I would prefer the intermediate solution and a fix as a follow-up.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay

*/
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 */
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't care it can stay.

if ((channel < AT86RF2XX_MIN_CHANNEL) ||
(channel > AT86RF2XX_MAX_CHANNEL) ||
if ((channel > AT86RF2XX_MAX_CHANNEL) ||
#if AT86RF2XX_MIN_CHANNEL /* is zero for sub-GHz */
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, its just style.


static trickle_t trickle = { .callback.func = &callback,
.callback.args = NULL };
static trickle_t trickle;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What was the problem with this one ?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the way of init the struct caused an error.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so separated definition and init

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe use

static trickle_t trickle = { .callback = { .func = &callback,
                                           .args = NULL } };

instead? It doesn't change the behavior and is the more correct version.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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"

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error was reported by clang on macOS, which is often more pedantic than gcc

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@cladmi
Copy link
Copy Markdown
Contributor

cladmi commented Nov 28, 2017

Only need to squash and wait for murdock.

@smlng
Copy link
Copy Markdown
Member Author

smlng commented Nov 28, 2017

squashed

@cladmi cladmi merged commit b54318c into RIOT-OS:master Nov 28, 2017
@kYc0o kYc0o mentioned this pull request Nov 28, 2017
pyropeter added a commit to beduino-project/RIOT that referenced this pull request Dec 1, 2017
This was made visible by RIOT-OS#7919. Broke build on GCC 7.2.

Probably a bug.
@aabadie aabadie added this to the Release 2018.01 milestone Jan 18, 2018
@smlng smlng deleted the make/wpedantic branch February 6, 2018 19:42
panail pushed a commit to panail/RIOT that referenced this pull request Oct 29, 2018
This was made visible by RIOT-OS#7919. Broke build on GCC 7.2.

Probably a bug.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: build system Area: Build system CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Community: Hack'n'ACK candidate This PR is a candidate for review and discussion during one of RIOT's monthly Hack'n'ACK parties Type: cleanup The issue proposes a clean-up / The PR cleans-up parts of the codebase / documentation Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants