[PATCH 3/7] src: Replace virAtomicIntGet() with g_atomic_int_get()

Michal Privoznik mprivozn at redhat.com
Sat Feb 1 06:33:45 UTC 2020


Signed-off-by: Michal Privoznik <mprivozn at redhat.com>
---
 src/nwfilter/nwfilter_dhcpsnoop.c | 12 ++++++------
 src/util/viratomic.h              |  9 ---------
 src/util/virsystemd.c             |  6 +++---
 3 files changed, 9 insertions(+), 18 deletions(-)

diff --git a/src/nwfilter/nwfilter_dhcpsnoop.c b/src/nwfilter/nwfilter_dhcpsnoop.c
index a1c0c0189e..074cffecb2 100644
--- a/src/nwfilter/nwfilter_dhcpsnoop.c
+++ b/src/nwfilter/nwfilter_dhcpsnoop.c
@@ -601,7 +601,7 @@ virNWFilterSnoopReqFree(virNWFilterSnoopReqPtr req)
     if (!req)
         return;
 
-    if (virAtomicIntGet(&req->refctr) != 0)
+    if (g_atomic_int_get(&req->refctr) != 0)
         return;
 
     /* free all leases */
@@ -1477,7 +1477,7 @@ virNWFilterDHCPSnoopThread(void *req0)
                 unsigned int diff;
 
                 /* submit packet to worker thread */
-                if (virAtomicIntGet(&pcapConf[i].qCtr) >
+                if (g_atomic_int_get(&pcapConf[i].qCtr) >
                     pcapConf[i].maxQSize) {
                     if (last_displayed_queue - time(0) > 10) {
                         last_displayed_queue = time(0);
@@ -1778,7 +1778,7 @@ virNWFilterSnoopLeaseFileSave(virNWFilterSnoopIPLeasePtr ipl)
 
     /* keep dead leases at < ~95% of file size */
     if (virAtomicIntInc(&virNWFilterSnoopState.wLeases) >=
-        virAtomicIntGet(&virNWFilterSnoopState.nLeases) * 20)
+        g_atomic_int_get(&virNWFilterSnoopState.nLeases) * 20)
         virNWFilterSnoopLeaseFileLoad();   /* load & refresh lease file */
 
  err_exit:
@@ -1809,7 +1809,7 @@ virNWFilterSnoopPruneIter(const void *payload,
     /*
      * have the entry removed if it has no leases and no one holds a ref
      */
-    del_req = ((req->start == NULL) && (virAtomicIntGet(&req->refctr) == 0));
+    del_req = ((req->start == NULL) && (g_atomic_int_get(&req->refctr) == 0));
 
     virNWFilterSnoopReqUnlock(req);
 
@@ -1973,9 +1973,9 @@ virNWFilterSnoopLeaseFileLoad(void)
 static void
 virNWFilterSnoopJoinThreads(void)
 {
-    while (virAtomicIntGet(&virNWFilterSnoopState.nThreads) != 0) {
+    while (g_atomic_int_get(&virNWFilterSnoopState.nThreads) != 0) {
         VIR_WARN("Waiting for snooping threads to terminate: %u",
-                 virAtomicIntGet(&virNWFilterSnoopState.nThreads));
+                 g_atomic_int_get(&virNWFilterSnoopState.nThreads));
         g_usleep(1000 * 1000);
     }
 }
diff --git a/src/util/viratomic.h b/src/util/viratomic.h
index 12b116a6cd..6c1764f7bf 100644
--- a/src/util/viratomic.h
+++ b/src/util/viratomic.h
@@ -26,15 +26,6 @@
 
 #include "internal.h"
 
-/**
- * virAtomicIntGet:
- * Gets the current value of atomic.
- *
- * This call acts as a full compiler and hardware memory barrier
- * (before the get)
- */
-#define virAtomicIntGet(v) g_atomic_int_get(v)
-
 /**
  * virAtomicIntSet:
  * Sets the value of atomic to newval.
diff --git a/src/util/virsystemd.c b/src/util/virsystemd.c
index a9ff782fb8..5b66094de5 100644
--- a/src/util/virsystemd.c
+++ b/src/util/virsystemd.c
@@ -154,7 +154,7 @@ virSystemdHasMachined(void)
     int ret;
     int val;
 
-    val = virAtomicIntGet(&virSystemdHasMachinedCachedValue);
+    val = g_atomic_int_get(&virSystemdHasMachinedCachedValue);
     if (val != -1)
         return val;
 
@@ -176,7 +176,7 @@ virSystemdHasLogind(void)
     int ret;
     int val;
 
-    val = virAtomicIntGet(&virSystemdHasLogindCachedValue);
+    val = g_atomic_int_get(&virSystemdHasLogindCachedValue);
     if (val != -1)
         return val;
 
@@ -352,7 +352,7 @@ int virSystemdCreateMachine(const char *name,
      */
 
     VIR_DEBUG("Attempting to create machine via systemd");
-    if (virAtomicIntGet(&hasCreateWithNetwork)) {
+    if (g_atomic_int_get(&hasCreateWithNetwork)) {
         virError error;
         memset(&error, 0, sizeof(error));
 
-- 
2.24.1




More information about the libvir-list mailing list