mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-05 07:38:20 +02:00
shared: fix behavior of NM_G_MUTEX_LOCKED()
The idea of NM_G_MUTEX_LOCKED() macro is not only to register a mutex
for unlocking (via nm_auto_unlock_g_mutex) but also to lock it at
the same time.
That is a useful helper macro. If you have to lock the mutex yourself,
it makes usage less convenient. At which point you don't need the macro
anymore and you should instead take full control and lock/unlock yourself.
Fix the macro and change behavior. The macro was not used so far, so
it's not a problem.
Fixes: dd33b3a14e ('shared: add nm_auto_unlock_g_mutex and NM_G_MUTEX_LOCKED() helper macros')
This commit is contained in:
parent
a5829ea6d1
commit
098ac7dbc0
1 changed files with 7 additions and 2 deletions
|
|
@ -1805,8 +1805,13 @@ NM_AUTO_DEFINE_FCN_VOID0(GMutex *, _nm_auto_unlock_g_mutex, g_mutex_unlock);
|
|||
|
||||
#define nm_auto_unlock_g_mutex nm_auto(_nm_auto_unlock_g_mutex)
|
||||
|
||||
#define _NM_G_MUTEX_LOCKED(lock, uniq) \
|
||||
nm_auto_unlock_g_mutex GMutex *NM_UNIQ_T(nm_lock, uniq) = (lock)
|
||||
#define _NM_G_MUTEX_LOCKED(lock, uniq) \
|
||||
_nm_unused nm_auto_unlock_g_mutex GMutex *NM_UNIQ_T(nm_lock, uniq) = ({ \
|
||||
GMutex *const _lock = (lock); \
|
||||
\
|
||||
g_mutex_lock(_lock); \
|
||||
_lock; \
|
||||
})
|
||||
|
||||
#define NM_G_MUTEX_LOCKED(lock) _NM_G_MUTEX_LOCKED(lock, NM_UNIQ)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue