Skip to content

Suppress Coverity warnings #11472

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

Conversation

hugueskamba
Copy link
Collaborator

@hugueskamba hugueskamba commented Sep 12, 2019

Description

Ignore the following Coverity warnings:

* cmsis_os1.c:270 Passing argument 4UL /* sizeof (void *) */ to function osMessageQueueNew which returns a value of type void * is suspicious.
* mbed_retarget.cpp:451 Argument cannot be negative (NEGATIVE_RETURNS). negative_returns: fd is passed to a parameter that cannot be negative. [Note: The source code implementation of the function has been overridden by a builtin model.]
* mbed_retarget.cpp:828 result_independent_of_operands: off > 2147483647 is always false regardless of the values of its operands. This occurs as the logical operand of if.

Pull request type

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

Reviewers

Release Notes

@hugueskamba hugueskamba force-pushed the hk-silence-bogus-coverity-warnings branch from 888f2a8 to 5288e87 Compare September 12, 2019 12:51
@ciarmcom ciarmcom requested review from a team September 12, 2019 13:00
@ciarmcom
Copy link
Member

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

@hugueskamba hugueskamba changed the title Suppress bogus Coverity warning Suppress bogus Coverity warnings Sep 12, 2019
@hugueskamba hugueskamba force-pushed the hk-silence-bogus-coverity-warnings branch from 5288e87 to 3a44ce6 Compare September 12, 2019 13:19
@@ -448,6 +448,7 @@ std::FILE *fdopen(FileHandle *fh, const char *mode)
}
// Then bind that to the C stream. If successful, C library
// takes ownership and responsibility to close.
// coverity[negative_returns]
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't understand the coverity warning.
Is it because std is missing?

std::FILE *stream = std::fdopen(fd, mode);

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.

Not sure but my wild guess is that it is related to IAR implementation of it...
GIven the end of the message (Note: The source code implementation of the function has been overridden by a builtin model.), it seems my guess could be right.

Copy link
Contributor

Choose a reason for hiding this comment

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

The diagnostic is correct - it's spotted that we could be passing a negative fd to ::fdopen.

(The "built-in model" bit is that it knows what ::fdopen is supposed to do, and it knows it shouldn't be getting a negative fd.)

Problem should be fixed by changing line 446 from if (!fd) to if (fd < 0). bind_to_fd returns negative on failure, not 0. 0 is actually a valid file descriptor, although it's reserved for console input.

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 hugueskamba force-pushed the hk-silence-bogus-coverity-warnings branch from 3a44ce6 to 93f50ee Compare September 12, 2019 14:45
@hugueskamba hugueskamba changed the title Suppress bogus Coverity warnings Suppress Coverity warnings Sep 12, 2019
@hugueskamba
Copy link
Collaborator Author

This force-push corrects the code where fdopen is used instead of silencing the warning.
I also removes "bogus" from the commit message.

@mbed-ci
Copy link

mbed-ci commented Sep 12, 2019

Test run: FAILED

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

Failed test jobs:

  • jenkins-ci/mbed-os-ci_greentea-test

@0xc0170
Copy link
Contributor

0xc0170 commented Sep 13, 2019

test restarted, internal issue

@0xc0170 0xc0170 merged commit 0c59bea into ARMmbed:master Sep 13, 2019
@hugueskamba hugueskamba deleted the hk-silence-bogus-coverity-warnings branch December 22, 2019 22:12
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