Skip to content

Conversation

@eparshut
Copy link
Contributor

@eparshut eparshut commented Aug 7, 2025

Fixed Coverity static analysis tool hits:

  • Wrapped with mutex the access to _N_(_ittapi_global).state in the get_collection_state() to ensure thread safety.
  • Added a return statement after calling bind_context_metadata_to_counter implemantation() from the dynamic library to prevent double-unlocking and unnecessary work.

}
return _N_(_ittapi_global).state;
state = _N_(_ittapi_global).state;
if (PTHREAD_SYMBOLS) __itt_mutex_unlock(&_N_(_ittapi_global).mutex);
Copy link
Contributor

Choose a reason for hiding this comment

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

Why init&lock are performed with macros and unlock with function?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

A macro is preferred for init and lock because it can inline platform-specific logic, atomic checks, and initialization steps directly into the calling code. This avoids function call overhead and ensures the mutex is initialized and locked efficiently.
The unlock __itt_mutex_unlock() is a simple function call of the pthread_mutex_unlock(), and it does not require the extra logic.
But I also don't like the inconsistency you pointed out, and I will take that into account in future code improvements, thanks for the comment!

@eparshut eparshut merged commit 0c57540 into intel:master Aug 8, 2025
16 checks passed
@eparshut eparshut deleted the coverity branch August 8, 2025 11:32
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.

4 participants