]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Directly use return value of atomic_compare_exchange_strong_explicit insteaf of compa...
authorOndřej Surý <ondrej@sury.org>
Thu, 23 Aug 2018 13:30:06 +0000 (15:30 +0200)
committerOndřej Surý <ondrej@sury.org>
Tue, 28 Aug 2018 10:15:39 +0000 (12:15 +0200)
lib/isc/rwlock.c

index b3151465a15ef9da520dece3c10d0fba46360e14..622cd7d27626c559c8c833ecf9b5167d51764076 100644 (file)
@@ -308,13 +308,13 @@ isc__rwlock_lock(isc_rwlock_t *rwl, isc_rwlocktype_t type) {
                }
 
                while (1) {
-                       int_fast32_t cntflag2 = 0;
-                       atomic_compare_exchange_strong_explicit
-                               (&rwl->cnt_and_flag, &cntflag2, WRITER_ACTIVE,
-                                memory_order_relaxed, memory_order_relaxed);
-
-                       if (cntflag2 == 0)
+                       int_fast32_t zero = 0;
+                       if (atomic_compare_exchange_strong_explicit
+                           (&rwl->cnt_and_flag, &zero, WRITER_ACTIVE,
+                            memory_order_relaxed, memory_order_relaxed))
+                       {
                                break;
+                       }
 
                        /* Another active reader or writer is working. */
                        LOCK(&rwl->lock);
@@ -409,7 +409,9 @@ isc_rwlock_trylock(isc_rwlock_t *rwl, isc_rwlocktype_t type) {
                if (!atomic_compare_exchange_strong_explicit
                    (&rwl->cnt_and_flag, &zero, WRITER_ACTIVE,
                     memory_order_relaxed, memory_order_relaxed))
+               {
                        return (ISC_R_LOCKBUSY);
+               }
 
                /*
                 * XXXJT: jump into the queue, possibly breaking the writer