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

Re: [Xen-devel] [PATCH v2 02/10] libx86: Proactively initialise error pointers



On 16.09.2019 17:26, Andrew Cooper wrote:
> On 16/09/2019 11:56, Jan Beulich wrote:
>> On 13.09.2019 21:27, Andrew Cooper wrote:
>>> --- a/tools/tests/cpu-policy/test-cpu-policy.c
>>> +++ b/tools/tests/cpu-policy/test-cpu-policy.c
>>> @@ -283,7 +283,7 @@ static void test_cpuid_deserialise_failure(void)
>>>      for ( size_t i = 0; i < ARRAY_SIZE(tests); ++i )
>>>      {
>>>          const struct test *t = &tests[i];
>>> -        uint32_t err_leaf = ~0u, err_subleaf = ~0u;
>>> +        uint32_t err_leaf, err_subleaf;
>>>          int rc;
>>>  
>>>          /* No writes should occur.  Use NULL to catch errors. */
>>> @@ -336,7 +336,7 @@ static void test_msr_deserialise_failure(void)
>>>      for ( size_t i = 0; i < ARRAY_SIZE(tests); ++i )
>>>      {
>>>          const struct test *t = &tests[i];
>>> -        uint32_t err_msr = ~0u;
>>> +        uint32_t err_msr;
>> I continue to be curious about the ~0u => ...
>>
>>> --- a/xen/lib/x86/cpuid.c
>>> +++ b/xen/lib/x86/cpuid.c
>>> @@ -381,6 +381,11 @@ int x86_cpuid_copy_from_buffer(struct cpuid_policy *p,
>>>      unsigned int i;
>>>      xen_cpuid_leaf_t data;
>>>  
>>> +    if ( err_leaf )
>>> +        *err_leaf = -1;
>>> +    if ( err_subleaf )
>>> +        *err_subleaf = -1;
>>> +
>>>      /*
>>>       * A well formed caller is expected to pass an array with leaves in 
>>> order,
>>>       * and without any repetitions.  However, due to per-vendor 
>>> differences,
>>> --- a/xen/lib/x86/msr.c
>>> +++ b/xen/lib/x86/msr.c
>>> @@ -55,6 +55,9 @@ int x86_msr_copy_from_buffer(struct msr_policy *p,
>>>      xen_msr_entry_t data;
>>>      int rc;
>>>  
>>> +    if ( err_msr )
>>> +        *err_msr = -1;
>> ... => -1 switch.
> 
> Its shorter to write, and less buggy when the type changes.
> 
> Any reason why this email is in private?

None at all - I have no idea how xen-devel managed to disappear
from the recipients list (I've re-added it now).

Jan

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.