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

Prevent unreachable statements and correct variable sizes. #11470

Merged
merged 1 commit into from
Sep 19, 2019

Conversation

hugueskamba
Copy link
Collaborator

Description

Fix the following warnings:

[Warning] USBAudio.cpp@666,20: [Pa182]: bit mask appears to contain significant bits that do not affect the result 
[Warning] USBAudio.cpp@704,0: [Pa182]: bit mask appears to contain significant bits that do not affect the result
[Warning] mbed_rtos_rtx.c@118,0: [Pe128]: loop is not reachable
[Warning] mbed_rtx_handlers.c@85,0: [Pe128]: loop is not reachable
[Warning] Semaphore.cpp@216,0: [Pe111]: statement is unreachable

Pull request type

[X] Fix
[ ] Refactor
[ ] Target update
[ ] Functionality change
[ ] Docs update
[ ] Test update
[ ] Breaking change

Reviewers

Release Notes

@ciarmcom ciarmcom requested review from a team September 12, 2019 09:00
@ciarmcom
Copy link
Member

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

@@ -114,6 +114,9 @@ MBED_NORETURN void mbed_rtos_start()
}

osKernelStart();
#if MBED_TRAP_ERRORS_ENABLED
Copy link
Contributor

Choose a reason for hiding this comment

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

Are you intending to change behaviour here, or are you thinking that MBED_ERROR's behaviour is conditional on this flag?

MBED_ERROR always kills the system. You can just remove the while (1).

If you're trying to reduce ROM size and make more error cases conditional, putting more MBED_TRAP_ERRORS_ENABLED conditions in might be a thing you could do, but it's a bit tangential.

Note that previously that flag was only on for debug profile - now it's on for develop and debug, not relase. It tends to catch RTOS errors like "claiming a mutex from IRQ".

Copy link
Collaborator Author

@hugueskamba hugueskamba Sep 12, 2019

Choose a reason for hiding this comment

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

I'll remove the infinite loop. I do not understand the reason for those statements that are expected not to be reached...

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Previously mbed_error wasn't marked "noreturn", so I can imagine compilers complaining about returning? It might have complained with osRtxErrorNotify being "noreturn" itself. Maybe the loops were to shut that up.

Or perhaps people were just being over-cautious - not trusting it.

(With the "noreturn" marking, the compiler will actually not be making it possible for mbed_error to return anyway - it'll crash if it did)

@@ -53,6 +53,7 @@ __NO_RETURN void osRtxIdleThread(void *argument)

__NO_RETURN uint32_t osRtxErrorNotify(uint32_t code, void *object_id)
{
#if MBED_TRAP_ERRORS_ENABLED
Copy link
Contributor

Choose a reason for hiding this comment

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

Same comment as above - are you intentionally killing stack overflow reports for release builds? If you want to do that, I suggest this isn't the place - you'd do better switching whatever the existing options are to make mbed_error not print anything and just halt the system. (Rather than change every callsite of mbed_error )

Otherwise, just remove the for loop.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Same comment as above.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@hugueskamba
Copy link
Collaborator Author

This force-push removes unreachable infinite loops.

@0xc0170
Copy link
Contributor

0xc0170 commented Sep 18, 2019

CI started

@mbed-ci
Copy link

mbed-ci commented Sep 18, 2019

Test run: SUCCESS

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

@0xc0170 0xc0170 merged commit 6fcd297 into ARMmbed:master Sep 19, 2019
@hugueskamba hugueskamba deleted the hk-fix-warnings branch November 18, 2019 15:09
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.

6 participants