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

Refactor OS::Mutex in CMake selection #2790

Draft
wants to merge 15 commits into
base: devel
Choose a base branch
from

Conversation

thomas-bc
Copy link
Collaborator

@thomas-bc thomas-bc commented Jun 27, 2024

Related Issue(s) #2722
Has Unit Tests (y/n) yes
Documentation Included (y/n) OSAL

Change Description

Refactor the Mutex part of the OSAL layer to use the new system!

Rationale

See #2722

WIP

Still polishing a few things, opening this as a draft to see how CI behaves

delete reinterpret_cast<pthread_mutex_t*>(this->m_handle);
}
PosixMutex::Status PosixMutex::release() {
PlatformIntType status = pthread_mutex_unlock(&this->m_handle.m_mutex_descriptor);

Check notice

Code scanning / CodeQL

Use of basic integral type Note

status uses the basic integral type int rather than a typedef with size and signedness.
this->m_handle = reinterpret_cast<POINTER_CAST>(handle);
}
PosixMutex::Status PosixMutex::take() {
PlatformIntType status = pthread_mutex_lock(&this->m_handle.m_mutex_descriptor);

Check notice

Code scanning / CodeQL

Use of basic integral type Note

status uses the basic integral type int rather than a typedef with size and signedness.
stat = pthread_mutex_init(handle,&attr);
FW_ASSERT(stat == 0,stat);
PosixMutex::~PosixMutex() {
PlatformIntType status = pthread_mutex_destroy(&this->m_handle.m_mutex_descriptor);

Check notice

Code scanning / CodeQL

Use of basic integral type Note

status uses the basic integral type int rather than a typedef with size and signedness.
pthread_mutexattr_t attr;
pthread_mutexattr_init(&attr);
// set to normal mutex type
PlatformIntType status = pthread_mutexattr_settype(&attribute, PTHREAD_MUTEX_NORMAL);

Check notice

Code scanning / CodeQL

Use of basic integral type Note

status uses the basic integral type int rather than a typedef with size and signedness.
@@ -70,5 +70,23 @@
return status;
}

Mutex::Status posix_status_to_mutex_status(PlatformIntType posix_status){

Check notice

Code scanning / CodeQL

Use of basic integral type Note

posix_status uses the basic integral type int rather than a typedef with size and signedness.
Os/Posix/Mutex.hpp Fixed Show fixed Hide fixed
Status release() override; //!< unlock the mutex and get return status
void lock() override; //!< lock the mutex
void unLock() override; //!< unlock the mutex
void unlock() { this->unLock(); } //!< alias for unLock to meet BasicLockable requirements

Check notice

Code scanning / CodeQL

More than one statement per line Note

This line contains 3 statements; only one is allowed.
void unLock(); //!< unlock the mutex
void unlock() { this->unLock(); } //!< alias for unLock to meet BasicLockable requirements
//! \brief default constructor
MutexInterface() = default;

Check notice

Code scanning / CodeQL

More than one statement per line Note

This line contains 2 statements; only one is allowed.
namespace Posix {
namespace Mutex {

struct PosixMutexHandle : public MutexHandle {

Check notice

Code scanning / CodeQL

More than one statement per line Note

This line contains 2 statements; only one is allowed.
@@ -70,5 +70,23 @@
return status;
}

Mutex::Status posix_status_to_mutex_status(PlatformIntType posix_status){

Check notice

Code scanning / CodeQL

Long function without assertion Note

All functions of more than 10 lines should have at least one assertion.
@@ -70,5 +70,23 @@
return status;
}

Mutex::Status posix_status_to_mutex_status(PlatformIntType posix_status){
Mutex::Status status = Mutex::Status::ERROR_OTHER;
switch (posix_status) {

Check warning

Code scanning / CodeQL

Unchecked function argument Warning

This use of parameter posix_status has not been checked.
PosixMutex::PosixMutex() : Os::MutexInterface(), m_handle() {
// set attributes
pthread_mutexattr_t attribute;
pthread_mutexattr_init(&attribute);

Check warning

Code scanning / CodeQL

Unchecked return value Warning

The return value of non-void function
pthread_mutexattr_init
is not checked.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant