Skip to content

Commit

Permalink
posix: semaphore: check return value of k_mutex_lock()
Browse files Browse the repository at this point in the history
This fixes CID 340851.

This should never fail, but it's also something that can be
easily verified.

Signed-off-by: Christopher Friedt <[email protected]>
  • Loading branch information
cfriedt authored and dleach02 committed Feb 6, 2024
1 parent b320899 commit ba639ed
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/posix/options/semaphore.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ static K_MUTEX_DEFINE(nsem_mutex);

static inline void nsem_list_lock(void)
{
k_mutex_lock(&nsem_mutex, K_FOREVER);
__unused int ret = k_mutex_lock(&nsem_mutex, K_FOREVER);

__ASSERT(ret == 0, "nsem_list_lock() failed: %d", ret);
}

static inline void nsem_list_unlock(void)
Expand Down

0 comments on commit ba639ed

Please sign in to comment.