Skip to content

SerialBase.h|cpp [-Wreorder] compiler warning fix #11839

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 8, 2019

Conversation

JanneKiiskila
Copy link
Contributor

Description (required)

The initialization order was not quite right, so aligning the .cpp
to match order .h. This hixes the following compiler warning:

[Warning] SerialBase.h@351,22: 'mbed::SerialBase::_flow2' will be initialized after [-Wreorder]
[Warning] SerialBase.h@343,22:   'bool mbed::SerialBase::_rx_enabled' [-Wreorder]
[Warning] SerialBase.cpp@26,1:   when initialized here [-Wreorder]

Summary of change (What the change is for and why)

Fix compiler warning in SerialBase.h|cpp.

Documentation (Details of any document updates required)

None.

Pull request type (required)

[x] Patch update (Bug fix / Target update / Docs update / Test update / Refactor)
[] Feature update (New feature / Functionality change / New API)
[] Major update (Breaking change E.g. Return code change / API behaviour change)

Test results (required)

[] No Tests required for this change (E.g docs only update)
[x] Covered by existing mbed-os tests (Greentea or Unittest)
[] Tests / results supplied as part of this PR

Release Notes (required for feature/major PRs)

Not worth mentioning in release notes.

@ciarmcom ciarmcom requested review from a team November 7, 2019 16:00
@ciarmcom
Copy link
Member

ciarmcom commented Nov 7, 2019

@JanneKiiskila, thank you for your changes.
@ARMmbed/mbed-os-core @ARMmbed/mbed-os-maintainers please review.

evedon
evedon previously requested changes Nov 7, 2019
_rx_enabled(true),
_tx_enabled(true),
_tx_pin(tx),
_rx_pin(rx),
Copy link
Contributor

Choose a reason for hiding this comment

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

, needs to be with #if DEVICE_SERIAL_FC or you can change the declaration order in .h

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah yes, missed that possibility. Good that we have CI.
Fixed it by re-ordering, force pushing a fix.

Copy link
Contributor

Choose a reason for hiding this comment

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

Counter-suggestion - prevent future messing around by changing this to C++11.

Put the initialisers in the member declarations:

#if DEVICE_SERIAL_FC
    Flow             _flow_type = Disabled;

etc

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Makes sense, definitely! Thanks!

@JanneKiiskila JanneKiiskila force-pushed the SerialBase-compwarning branch from 159b2c5 to dba19e2 Compare November 8, 2019 09:19
This fixes:

```
[Warning] SerialBase.h@351,22: 'mbed::SerialBase::_flow2' will be initialized after [-Wreorder]
[Warning] SerialBase.h@343,22:   'bool mbed::SerialBase::_rx_enabled' [-Wreorder]
[Warning] SerialBase.cpp@26,1:   when initialized here [-Wreorder]

```

by using C++11 style initializer for SerialBase

Kudos to Kevin Bracey, as her his suggestion - we can drop the initializer
list if we just set the values directly in the SerialBase.h. No need to
worry about the "right order" after that.
@JanneKiiskila JanneKiiskila force-pushed the SerialBase-compwarning branch from dba19e2 to 916b91f Compare November 8, 2019 09:22
@JanneKiiskila
Copy link
Contributor Author

Squashed, force pushed.

@0xc0170
Copy link
Contributor

0xc0170 commented Nov 8, 2019

CI started

@0xc0170 0xc0170 requested a review from evedon November 8, 2019 09:27
@mbed-ci
Copy link

mbed-ci commented Nov 8, 2019

Test run: SUCCESS

Summary: 11 of 11 test jobs passed
Build number : 1
Build artifacts

@0xc0170 0xc0170 merged commit dd70938 into ARMmbed:master Nov 8, 2019
@adbridge
Copy link
Contributor

This is sitting on top of #10924 which is currently targeting 6.0

@adbridge adbridge added release-version: 6.0.0-alpha-1 First pre-release version of 6.0.0 and removed release-version: 5.14.2 labels Nov 18, 2019
@0xc0170 0xc0170 added release-version: 5.15.0-rc1 and removed release-version: 6.0.0-alpha-1 First pre-release version of 6.0.0 labels Nov 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants