Re: [PATCH v11 33/46] KVM: selftests: Hyper-V PV IPI selftest

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Sean Christopherson <seanjc@xxxxxxxxxx> writes:

> On Tue, Oct 04, 2022, Vitaly Kuznetsov wrote:

...

>> +
>> +	r = pthread_cancel(thread);
>> +	TEST_ASSERT(r == 0,
>
> !r is generally preferred over "r == 0"
>
>> +		    "pthread_cancel on vcpu_id=%d failed with errno=%d",
>> +		    vcpu->id, r);
>
> Do you happen to know if errno is preserved?  I.e. if TEST_ASSERT()'s print of
> errno will capture the right errno?  If so, this and the pthread_join() assert
> can be:
>
> 	TEST_ASSERT(!r, pthread_cancel() failed on vcpu_id=%d, vcpu->id);
>

The example from 'man 3 pthread_cancel' makes me think errno is not
set. 'man 3 errno' confirms that:

"
       Note  that the POSIX threads APIs do not set errno on error.
Instead, on failure they return an error number as the function result.
These error numbers have the same meanings as the error numbers returned
in errno by other APIs.
"

but nothing stops us from doing something like

#include <errno.h>
...

errno = pthread_cancel(thread);
TEST_ASSERT(!errno, pthread_cancel() failed on vcpu_id=%d, vcpu->id);

I believe.

-- 
Vitaly




[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux