Skip to contentSkip to conversation

api-gcc.h: fix typos in the functions atomic_add_*

PATCH New Junchang Wang 1 participant 1 message Sep 29, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 api-gcc.h: fix typos in the functions atomic_add_*

The typo in atomic_add_return() incurs tricky bugs. For example, the current atomic_dec_return() is indeed an atomic_add_return(). A similar typo appears in the function atomic_add_negative().

---
 CodeSamples/api-pthreads/api-gcc.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
CodeSamples/api-pthreads/api-gcc.h +2 -2
index fbbedf2..9ad8a68 100644
@@ -140,7 +140,7 @@ static __inline__ int atomic_inc_and_test(atomic_t *v)
  */
 static __inline__ int atomic_add_negative(int i, atomic_t *v)
 {
-	return __atomic_add_fetch(&v->counter, 1, __ATOMIC_SEQ_CST) < 0;
+	return __atomic_add_fetch(&v->counter, i, __ATOMIC_SEQ_CST) < 0;
 }
 
 /**
@@ -152,7 +152,7 @@ static __inline__ int atomic_add_negative(int i, atomic_t *v)
  */
 static __inline__ int atomic_add_return(int i, atomic_t *v)
 {
-	return __atomic_add_fetch(&v->counter, 1, __ATOMIC_SEQ_CST);
+	return __atomic_add_fetch(&v->counter, i, __ATOMIC_SEQ_CST);
 }
 
 static __inline__ int atomic_sub_return(int i, atomic_t *v)
Signature · 1 line
2.7.4