Skip to content

cpu/saml21: Fix possibly uninitialized variable in pm.c.#9244

Merged
jia200x merged 1 commit intoRIOT-OS:masterfrom
jcarrano:fix-saml21-pm-unititialized
Jun 11, 2018
Merged

cpu/saml21: Fix possibly uninitialized variable in pm.c.#9244
jia200x merged 1 commit intoRIOT-OS:masterfrom
jcarrano:fix-saml21-pm-unititialized

Conversation

@jcarrano
Copy link
Copy Markdown
Contributor

Contribution description

The code in pm.c for saml32 was missing a default case, this triggered a -Wmaybe-unititialized.

-Wmaybe-unititialized warnings are somewhat unreliable (see this answer). Depending on optimization options, sometimes the compiler is able to detect it (sometimes it gives a false positive). Would it be a good idea to turn this warning back into a warning to avoid having unpredictable compilation errors?

@jcarrano
Copy link
Copy Markdown
Contributor Author

Also, would it be a good idea to enable -Wswitch-default to warn about switch statements without default case?

@jcarrano jcarrano requested a review from kaspar030 May 30, 2018 11:46
@dylad
Copy link
Copy Markdown
Member

dylad commented May 30, 2018

Just wondering : Can't we just replace case 2 by default ?

@basilfx
Copy link
Copy Markdown
Member

basilfx commented May 30, 2018

@dylad: catching the default case is better.

@tcschmidt
Copy link
Copy Markdown
Member

@josephnoir any advise here?

@jcarrano
Copy link
Copy Markdown
Contributor Author

@dylad I think that having

default:
case 2:
  code();

Makes it clear that "2" is an expected value, and that for other values we do the same as if the value was 2. Of course, if "case 2:" is omitted, the program is perfectly equivalent, but in my opinion less clear.

@jcarrano jcarrano requested a review from basilfx June 11, 2018 11:52
@dylad
Copy link
Copy Markdown
Member

dylad commented Jun 11, 2018

Sure ! I was just wondering.
If we take this option, please add a comment /* Falls through */ so we won't raise a new compiler warning later.
edit : if needed

@jcarrano
Copy link
Copy Markdown
Contributor Author

@dylad Done.

@jia200x jia200x added the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label Jun 11, 2018
@jia200x
Copy link
Copy Markdown
Member

jia200x commented Jun 11, 2018

Murdock is green.
@kaspar030 @dylad @basilfx is it ok for you to merge this PR?

Copy link
Copy Markdown
Member

@dylad dylad left a comment

Choose a reason for hiding this comment

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

I'm fine with this change.
ACK

@jcarrano
Copy link
Copy Markdown
Contributor Author

Should I rebase?

@jia200x
Copy link
Copy Markdown
Member

jia200x commented Jun 11, 2018

@jcarrano yup. And then we merge

@jcarrano jcarrano force-pushed the fix-saml21-pm-unititialized branch from 1de1397 to da85094 Compare June 11, 2018 16:36
@jcarrano
Copy link
Copy Markdown
Contributor Author

Also, would it be a good idea to enable -Wswitch-default to warn about switch statements without default case?

What is the correct place to discuss such a proposal?

@jia200x
Copy link
Copy Markdown
Member

jia200x commented Jun 11, 2018

@jcarrano either a GH issue or devel list

@jia200x
Copy link
Copy Markdown
Member

jia200x commented Jun 11, 2018

Murdock green and go

@jnohlgard
Copy link
Copy Markdown
Member

@jcarrano Create a new PR for it. It sounds like a good idea to enable that warning for all platforms which support it.

@jia200x
Copy link
Copy Markdown
Member

jia200x commented Jun 11, 2018

Murdock green -> GO

@jia200x jia200x merged commit 0d0628e into RIOT-OS:master Jun 11, 2018
@jcarrano jcarrano deleted the fix-saml21-pm-unititialized branch June 12, 2018 08:07
@cladmi cladmi added this to the Release 2018.07 milestone Jul 10, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants