Skip to content
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

Fix trivial compiler Warnings #13476

Merged
merged 28 commits into from
Sep 7, 2020
Merged

Fix trivial compiler Warnings #13476

merged 28 commits into from
Sep 7, 2020

Conversation

talorion
Copy link
Contributor

@talorion talorion commented Aug 22, 2020

Summary of changes

Fixed some trivial warnings with ARM_GCC and default profile.

Following warnings were fixed:

[Warning] CellularContext.cpp@121,20: comparison of integer expressions of different signedness: 'int' and 'size_t' {aka 'unsigned int'} [-Wsign-compare]
[Warning] CellularStateMachine.cpp@310,13: format '%d' expects argument of type 'int', but argument 4 has type 'std::chrono::duration<int, std::ratio<1, 1000> >' [-Wformat=]
[Warning] CellularStateMachine.cpp@327,13: format '%d' expects argument of type 'int', but argument 4 has type 'std::chrono::duration<int, std::ratio<1, 1000> >' [-Wformat=]
[Warning] CellularStateMachine.cpp@411,13: format '%d' expects argument of type 'int', but argument 4 has type 'std::chrono::duration<int, std::ratio<1, 1000> >' [-Wformat=]
[Warning] CellularStateMachine.cpp@476,17: format '%d' expects argument of type 'int', but argument 4 has type 'std::chrono::duration<int, std::ratio<1, 1000> >' [-Wformat=]
[Warning] CellularStateMachine.cpp@490,17: format '%d' expects argument of type 'int', but argument 4 has type 'std::chrono::duration<int, std::ratio<1, 1000> >' [-Wformat=]
[Warning] CellularStateMachine.cpp@638,21: format '%d' expects argument of type 'int', but argument 4 has type 'std::chrono::duration<int>' [-Wformat=]
[Warning] QUECTEL_BC95_CellularStack.cpp@228,48: suggest parentheses around '&&' within '||' [-Wparentheses]
[Warning] TELIT_ME310_CellularStack.cpp@69,9: unused variable 'modem_connect_id' [-Wunused-variable]
[Warning] TELIT_ME310_CellularStack.cpp@227,9: unused variable 'modem_connect_id' [-Wunused-variable]
[Warning] TELIT_ME310_CellularStack.cpp@229,9: unused variable 'err' [-Wunused-variable]
[Warning] TELIT_ME310_CellularStack.cpp@402,21: variable 'data_left' set but not used [-Wunused-but-set-variable]
[Warning] TELIT_ME310_CellularStack.cpp@443,34: 'int mbed::TimerBase::read_ms() const' is deprecated: Use the Chrono-based elapsed_time method.  If integer milliseconds are needed, you can use `duration_cast<milliseconds>(elapsed_time()).count()` [since mbed-os-6.0.0] [-Wdeprecated-declarations]
[Warning] UBLOX_AT_CellularStack.cpp@172,13: unused variable 'ch' [-Wunused-variable]
[Warning] UBLOX_AT_CellularStack.cpp@375,53: comparison of integer expressions of different signedness: 'unsigned int' and 'intptr_t' {aka 'int'} [-Wsign-compare]
[Warning] ppp_service_if.cpp@520,124: 'int events::EventQueue::call_in(int, F) [with F = mbed::Callback<void()>]' is deprecated: Pass a chrono duration, not an integer millisecond count. For example use `5s` rather than `5000`. [since mbed-os-6.0.0] [-Wdeprecated-declarations]
[Warning] ppp_service.cpp@361,74: 'bool rtos::Semaphore::try_acquire_for(uint32_t)' is deprecated: Pass a chrono duration, not an integer millisecond count. For example use `5s` rather than `5000`. [since mbed-os-6.0.0] [-Wdeprecated-declarations]
[Warning] tcp.c@86,20: 'trace_tcp_flags' defined but not used [-Wunused-function]
[Warning] nsapi_dns.cpp@51,24: comparison of integer expressions of different signedness: 'int' and 'unsigned int' [-Wsign-compare]
[Warning] nsapi_dns.cpp@492,28: comparison of integer expressions of different signedness: 'int' and 'unsigned int' [-Wsign-compare]
[Warning] nsapi_dns.cpp@51,24: comparison of integer expressions of different signedness: 'int' and 'unsigned int' [-Wsign-compare]
[Warning] SFDP.cpp@409,22: comparison of integer expressions of different signedness: 'long long unsigned int' and 'int' [-Wsign-compare]

Impact of changes

Migration actions required

Documentation

None


Pull request type

[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

[] 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

Reviewers


@ciarmcom ciarmcom added the release-type: patch Indentifies a PR as containing just a patch label Aug 22, 2020
@ciarmcom ciarmcom requested review from a team August 22, 2020 13:30
@ciarmcom
Copy link
Member

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

@ladislas
Copy link
Contributor

Nice! wanted to do the same :)

@talorion
Copy link
Contributor Author

talorion commented Aug 24, 2020

https://github.com/orgs/ARMmbed/teams/mbed-os-maintainers :
continuous-integration/travis-ci/pr has the error The program 'arm-none-eabi-gcc' is currently not installed. To run 'arm-none-eabi-gcc' please ask your administrator to install the package 'gcc-arm-none-eabi'.
since none of my changes touch the tools or the setup of the containers i don't think this is related to my PR

@0xc0170
Copy link
Contributor

0xc0170 commented Aug 24, 2020

@talorion Would you be able to rebase on the latest master?

@talorion
Copy link
Contributor Author

@talorion Would you be able to rebase on the latest master?

@0xc0170 i did rebase to the latest master still the same problem

@0xc0170
Copy link
Contributor

0xc0170 commented Aug 24, 2020

@talorion Can you please rebase, the history looks incorrect (bad rebase?)

@0xc0170
Copy link
Contributor

0xc0170 commented Aug 24, 2020

Thanks for fixing these warnings 👍 I'll review once the history is correct (to make sure I am not reviewing unrelated changes).

Copy link
Contributor

@0xc0170 0xc0170 left a comment

Choose a reason for hiding this comment

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

It needs rebase as requested above

@mergify mergify bot dismissed 0xc0170’s stale review August 24, 2020 12:44

Pull request has been modified.

@0xc0170 0xc0170 self-requested a review August 24, 2020 15:22
hugueskamba
hugueskamba previously approved these changes Aug 27, 2020
@@ -440,7 +440,7 @@ nsapi_size_or_error_t TELIT_ME310_CellularStack::socket_recvfrom_impl(CellularSo
// read() should not fail
success = false;
}
} else if (timer.read_ms() < ME310_SOCKET_TIMEOUT) {
} else if (std::chrono::duration_cast<std::chrono::milliseconds>(timer.elapsed_time()) < socket_timeout) {
Copy link
Contributor

Choose a reason for hiding this comment

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

The duration cast is not required here. You only need it when doing a precision-losing conversion.

Comparisons are always exact, regardless of the precision on either side. The less-precise thing gets converted to the more-precise thing.

Suggested change
} else if (std::chrono::duration_cast<std::chrono::milliseconds>(timer.elapsed_time()) < socket_timeout) {
} else if (timer.elapsed_time() < socket_timeout) {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i changed it accordingly to your suggestions

@@ -372,7 +371,7 @@ UBLOX_AT_CellularStack::CellularSocket *UBLOX_AT_CellularStack::find_socket(int
{
CellularSocket *socket = NULL;

for (unsigned int x = 0; (socket == NULL) && (x < _device.get_property(AT_CellularDevice::PROPERTY_SOCKET_COUNT)); x++) {
for (intptr_t x = 0; (socket == NULL) && (x < _device.get_property(AT_CellularDevice::PROPERTY_SOCKET_COUNT)); x++) {
Copy link
Contributor

Choose a reason for hiding this comment

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

intptr_t? That's not what you want here. (It's for storing pointers as integers).

You want size_t or ptrdiff_t, depending on whether you need it to be signed or not.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i changed it accordingly to your suggestions

@@ -60,7 +60,7 @@ extern "C" { // "pppos.h" is missing extern C
/* Timeout to wait for PPP connection to be terminated
* (LCP Terminate-Request is answered with Terminate-Ack)
*/
#define PPP_TERMINATION_TIMEOUT 30000
#define PPP_TERMINATION_TIMEOUT 30s;
Copy link
Contributor

Choose a reason for hiding this comment

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

This shouldn't work - you don't have a using directive (and it's got a stray semicolon). Not used?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i changed it accordingly to your suggestions

@hugueskamba hugueskamba dismissed their stale review August 27, 2020 16:55

Please take into account Kevin's comment.

@talorion
Copy link
Contributor Author

talorion commented Sep 3, 2020

ping

@mergify mergify bot added needs: CI and removed needs: review labels Sep 3, 2020
@0xc0170
Copy link
Contributor

0xc0170 commented Sep 4, 2020

CI started

@mbed-ci
Copy link

mbed-ci commented Sep 4, 2020

Jenkins CI Test : ✔️ SUCCESS

Build Number: 2 | 🔒 Jenkins CI Job | 🌐 Logs & Artifacts

CLICK for Detailed Summary

jobs Status
jenkins-ci/mbed-os-ci_unittests ✔️
jenkins-ci/mbed-os-ci_build-ARM ✔️
jenkins-ci/mbed-os-ci_build-GCC_ARM ✔️
jenkins-ci/mbed-os-ci_greentea-test ✔️
jenkins-ci/mbed-os-ci_cloud-client-pytest ✔️
jenkins-ci/mbed-os-ci_dynamic-memory-usage ✔️
jenkins-ci/mbed-os-ci_wisun-mesh-test ✔️

@0xc0170 0xc0170 merged commit b2ac609 into ARMmbed:master Sep 7, 2020
@mergify mergify bot removed the ready for merge label Sep 7, 2020
@talorion talorion deleted the bugfix/fix-warnings branch September 7, 2020 12:46
@mbedmain mbedmain added release-version: 6.3.0 Release-pending and removed release-type: patch Indentifies a PR as containing just a patch Release-pending labels Sep 14, 2020
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.

9 participants