mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-20 07:59:00 +00:00
virthread: Make sure virOnce() returns -1 on error
Since its introduction in v0.9.1~65 the virOnce() was expected to follow the usual retval logic (0 for success, a negative number for failure). However, that was never the case. On the other hand, looking into glibc and musl the pthread_once() never returns anything other than zero (uclibc-ng seems to not implement pthread_once()), therefore we never really hit any problem. But for code cleanliness (and to match POSIX documentation), let's change to code so that our retval logic is honoured. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
1764b305e6
commit
d2a506eb67
@ -39,7 +39,15 @@
|
|||||||
|
|
||||||
int virOnce(virOnceControl *once, virOnceFunc init)
|
int virOnce(virOnceControl *once, virOnceFunc init)
|
||||||
{
|
{
|
||||||
return pthread_once(&once->once, init);
|
int ret;
|
||||||
|
|
||||||
|
ret = pthread_once(&once->once, init);
|
||||||
|
if (ret != 0) {
|
||||||
|
errno = ret;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user