[PATCH V2 1/3] rename arguments of virthread functions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



For keeping consistence of other functions in virthread.c,
rename arguments 'm', 'c' to 'mutex', 'rwlock' and 'cond'.

Signed-off-by: Jincheng Miao <jmiao@xxxxxxxxxx>
---
 src/util/virthread.c | 65 ++++++++++++++++++++++++++--------------------------
 src/util/virthread.h | 33 +++++++++++++-------------
 2 files changed, 50 insertions(+), 48 deletions(-)

diff --git a/src/util/virthread.c b/src/util/virthread.c
index 7e841d1..e22cadd 100644
--- a/src/util/virthread.c
+++ b/src/util/virthread.c
@@ -48,13 +48,13 @@ int virOnce(virOnceControlPtr once, virOnceFunc init)
 }
 
 
-int virMutexInit(virMutexPtr m)
+int virMutexInit(virMutexPtr mutex)
 {
     int ret;
     pthread_mutexattr_t attr;
     pthread_mutexattr_init(&attr);
     pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_NORMAL);
-    ret = pthread_mutex_init(&m->lock, &attr);
+    ret = pthread_mutex_init(&mutex->lock, &attr);
     pthread_mutexattr_destroy(&attr);
     if (ret != 0) {
         errno = ret;
@@ -63,13 +63,13 @@ int virMutexInit(virMutexPtr m)
     return 0;
 }
 
-int virMutexInitRecursive(virMutexPtr m)
+int virMutexInitRecursive(virMutexPtr mutex)
 {
     int ret;
     pthread_mutexattr_t attr;
     pthread_mutexattr_init(&attr);
     pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
-    ret = pthread_mutex_init(&m->lock, &attr);
+    ret = pthread_mutex_init(&mutex->lock, &attr);
     pthread_mutexattr_destroy(&attr);
     if (ret != 0) {
         errno = ret;
@@ -78,26 +78,26 @@ int virMutexInitRecursive(virMutexPtr m)
     return 0;
 }
 
-void virMutexDestroy(virMutexPtr m)
+void virMutexDestroy(virMutexPtr mutex)
 {
-    pthread_mutex_destroy(&m->lock);
+    pthread_mutex_destroy(&mutex->lock);
 }
 
-void virMutexLock(virMutexPtr m)
+void virMutexLock(virMutexPtr mutex)
 {
-    pthread_mutex_lock(&m->lock);
+    pthread_mutex_lock(&mutex->lock);
 }
 
-void virMutexUnlock(virMutexPtr m)
+void virMutexUnlock(virMutexPtr mutex)
 {
-    pthread_mutex_unlock(&m->lock);
+    pthread_mutex_unlock(&mutex->lock);
 }
 
 
-int virRWLockInit(virRWLockPtr m)
+int virRWLockInit(virRWLockPtr rwlock)
 {
     int ret;
-    ret = pthread_rwlock_init(&m->lock, NULL);
+    ret = pthread_rwlock_init(&rwlock->lock, NULL);
     if (ret != 0) {
         errno = ret;
         return -1;
@@ -105,59 +105,60 @@ int virRWLockInit(virRWLockPtr m)
     return 0;
 }
 
-void virRWLockDestroy(virRWLockPtr m)
+void virRWLockDestroy(virRWLockPtr rwlock)
 {
-    pthread_rwlock_destroy(&m->lock);
+    pthread_rwlock_destroy(&rwlock->lock);
 }
 
 
-void virRWLockRead(virRWLockPtr m)
+void virRWLockRead(virRWLockPtr rwlock)
 {
-    pthread_rwlock_rdlock(&m->lock);
+    pthread_rwlock_rdlock(&rwlock->lock);
 }
 
-void virRWLockWrite(virRWLockPtr m)
+void virRWLockWrite(virRWLockPtr rwlock)
 {
-    pthread_rwlock_wrlock(&m->lock);
+    pthread_rwlock_wrlock(&rwlock->lock);
 }
 
 
-void virRWLockUnlock(virRWLockPtr m)
+void virRWLockUnlock(virRWLockPtr rwlock)
 {
-    pthread_rwlock_unlock(&m->lock);
+    pthread_rwlock_unlock(&rwlock->lock);
 }
 
-int virCondInit(virCondPtr c)
+int virCondInit(virCondPtr cond)
 {
     int ret;
-    if ((ret = pthread_cond_init(&c->cond, NULL)) != 0) {
+    if ((ret = pthread_cond_init(&cond->cond, NULL)) != 0) {
         errno = ret;
         return -1;
     }
     return 0;
 }
 
-int virCondDestroy(virCondPtr c)
+int virCondDestroy(virCondPtr cond)
 {
     int ret;
-    if ((ret = pthread_cond_destroy(&c->cond)) != 0) {
+    if ((ret = pthread_cond_destroy(&cond->cond)) != 0) {
         errno = ret;
         return -1;
     }
     return 0;
 }
 
-int virCondWait(virCondPtr c, virMutexPtr m)
+int virCondWait(virCondPtr cond, virMutexPtr mutex)
 {
     int ret;
-    if ((ret = pthread_cond_wait(&c->cond, &m->lock)) != 0) {
+    if ((ret = pthread_cond_wait(&cond->cond, &mutex->lock)) != 0) {
         errno = ret;
         return -1;
     }
     return 0;
 }
 
-int virCondWaitUntil(virCondPtr c, virMutexPtr m, unsigned long long whenms)
+int virCondWaitUntil(virCondPtr cond, virMutexPtr mutex,
+                     unsigned long long whenms)
 {
     int ret;
     struct timespec ts;
@@ -165,21 +166,21 @@ int virCondWaitUntil(virCondPtr c, virMutexPtr m, unsigned long long whenms)
     ts.tv_sec = whenms / 1000;
     ts.tv_nsec = (whenms % 1000) * 1000;
 
-    if ((ret = pthread_cond_timedwait(&c->cond, &m->lock, &ts)) != 0) {
+    if ((ret = pthread_cond_timedwait(&cond->cond, &mutex->lock, &ts)) != 0) {
         errno = ret;
         return -1;
     }
     return 0;
 }
 
-void virCondSignal(virCondPtr c)
+void virCondSignal(virCondPtr cond)
 {
-    pthread_cond_signal(&c->cond);
+    pthread_cond_signal(&cond->cond);
 }
 
-void virCondBroadcast(virCondPtr c)
+void virCondBroadcast(virCondPtr cond)
 {
-    pthread_cond_broadcast(&c->cond);
+    pthread_cond_broadcast(&cond->cond);
 }
 
 struct virThreadArgs {
diff --git a/src/util/virthread.h b/src/util/virthread.h
index 4b92a43..7c71c6b 100644
--- a/src/util/virthread.h
+++ b/src/util/virthread.h
@@ -122,35 +122,36 @@ unsigned long long virThreadID(virThreadPtr thread);
 int virOnce(virOnceControlPtr once, virOnceFunc init)
     ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK;
 
-int virMutexInit(virMutexPtr m) ATTRIBUTE_RETURN_CHECK;
-int virMutexInitRecursive(virMutexPtr m) ATTRIBUTE_RETURN_CHECK;
-void virMutexDestroy(virMutexPtr m);
+int virMutexInit(virMutexPtr mutex) ATTRIBUTE_RETURN_CHECK;
+int virMutexInitRecursive(virMutexPtr mutex) ATTRIBUTE_RETURN_CHECK;
+void virMutexDestroy(virMutexPtr mutex);
 
-void virMutexLock(virMutexPtr m);
-void virMutexUnlock(virMutexPtr m);
+void virMutexLock(virMutexPtr mutex);
+void virMutexUnlock(virMutexPtr mutex);
 
 
-int virRWLockInit(virRWLockPtr m) ATTRIBUTE_RETURN_CHECK;
-void virRWLockDestroy(virRWLockPtr m);
+int virRWLockInit(virRWLockPtr rwlock) ATTRIBUTE_RETURN_CHECK;
+void virRWLockDestroy(virRWLockPtr rwlock);
 
-void virRWLockRead(virRWLockPtr m);
-void virRWLockWrite(virRWLockPtr m);
-void virRWLockUnlock(virRWLockPtr m);
+void virRWLockRead(virRWLockPtr rwlock);
+void virRWLockWrite(virRWLockPtr rwlock);
+void virRWLockUnlock(virRWLockPtr rwlock);
 
 
-int virCondInit(virCondPtr c) ATTRIBUTE_RETURN_CHECK;
-int virCondDestroy(virCondPtr c);
+int virCondInit(virCondPtr cond) ATTRIBUTE_RETURN_CHECK;
+int virCondDestroy(virCondPtr cond);
 
 /* virCondWait, virCondWaitUntil:
  * These functions can return without the associated predicate
  * changing value. Therefore in nearly all cases they
  * should be enclosed in a while loop that checks the predicate.
  */
-int virCondWait(virCondPtr c, virMutexPtr m) ATTRIBUTE_RETURN_CHECK;
-int virCondWaitUntil(virCondPtr c, virMutexPtr m, unsigned long long whenms) ATTRIBUTE_RETURN_CHECK;
+int virCondWait(virCondPtr cond, virMutexPtr mutex) ATTRIBUTE_RETURN_CHECK;
+int virCondWaitUntil(virCondPtr cond, virMutexPtr mutex,
+                     unsigned long long whenms) ATTRIBUTE_RETURN_CHECK;
 
-void virCondSignal(virCondPtr c);
-void virCondBroadcast(virCondPtr c);
+void virCondSignal(virCondPtr cond);
+void virCondBroadcast(virCondPtr cond);
 
 
 typedef void (*virThreadLocalCleanup)(void *);
-- 
1.8.3.1

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]