mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-30 22:05:36 +00:00
zdtm/lib: Check EWOULDBLOCK in errno instead of -EWOULDBLOCK
Syscalls do return negative value in case of an error. But errno contains the error code itself. Add uint32_t to sys_futex() definition. sizeof(unsigned int) might be not 4 bytes. Signed-off-by: Dmitry Safonov <dima@arista.com> Signed-off-by: Adrian Reber <areber@redhat.com> Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
This commit is contained in:
committed by
Andrei Vagin
parent
433bffb411
commit
d967ecf7c5
@@ -23,8 +23,8 @@ typedef struct {
|
||||
#define FUTEX_ABORT_FLAG (0x80000000)
|
||||
#define FUTEX_ABORT_RAW (-1U)
|
||||
|
||||
static inline int sys_futex(unsigned int *uaddr, int op, unsigned int val, const struct timespec *timeout,
|
||||
int *uaddr2, unsigned int val3)
|
||||
static inline int sys_futex(uint32_t *uaddr, int op, uint32_t val, const struct timespec *timeout,
|
||||
uint32_t *uaddr2, uint32_t val3)
|
||||
{
|
||||
return syscall(__NR_futex, uaddr, op, val, timeout, uaddr2, val3);
|
||||
}
|
||||
@@ -142,11 +142,11 @@ static void inline mutex_lock(mutex_t *m)
|
||||
uint32_t c;
|
||||
int ret;
|
||||
|
||||
while ((c = atomic_inc(&m->raw))) {
|
||||
while ((c = atomic_inc(&m->raw)) != 0) {
|
||||
ret = sys_futex(&m->raw, FUTEX_WAIT, c + 1, NULL, NULL, 0);
|
||||
if (ret < 0)
|
||||
pr_perror("futex");
|
||||
BUG_ON(ret < 0 && errno != -EWOULDBLOCK);
|
||||
BUG_ON(ret < 0 && errno != EWOULDBLOCK);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user