Skip to content

Commit 9757789

Browse files
luca-barbieriH. Peter Anvin
authored andcommitted
lib: Fix atomic64_add_unless return value convention
atomic64_add_unless must return 1 if it perfomed the add and 0 otherwise. The generic implementation did the opposite thing. Reported-by: H. Peter Anvin <hpa@zytor.com> Confirmed-by: Paul Mackerras <paulus@samba.org> Signed-off-by: Luca Barbieri <luca@luca-barbieri.com> LKML-Reference: <1267469749-11878-4-git-send-email-luca@luca-barbieri.com> Signed-off-by: H. Peter Anvin <hpa@zytor.com>
1 parent 6e6104f commit 9757789

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/atomic64.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,12 +162,12 @@ int atomic64_add_unless(atomic64_t *v, long long a, long long u)
162162
{
163163
unsigned long flags;
164164
spinlock_t *lock = lock_addr(v);
165-
int ret = 1;
165+
int ret = 0;
166166

167167
spin_lock_irqsave(lock, flags);
168168
if (v->counter != u) {
169169
v->counter += a;
170-
ret = 0;
170+
ret = 1;
171171
}
172172
spin_unlock_irqrestore(lock, flags);
173173
return ret;

0 commit comments

Comments
 (0)