Re: [kvm-unit-tests PATCH v2 1/2] s390x: Remove assert from arch_def.h

Janosch Frank
2021-10-05T13:58:30Z

On 10/5/21 15:51, Janis Schoetterl-Glausch wrote:
> On 10/5/21 2:51 PM, Janosch Frank wrote:
>> On 10/5/21 11:11, Janis Schoetterl-Glausch wrote:
>>> Do not use asserts in arch_def.h so it can be included by snippets.
>>> The caller in stsi.c does not need to be adjusted, returning -1 causes
>>> the test to fail.
>>>
>>> Signed-off-by: Janis Schoetterl-Glausch <scgl@linux.ibm.com>
>>
>> A few days ago I had a minute to investigate what needed to be added to be able to link the libcflat. Fortunately it wasn't a lot and I'll try to post it this week so this patch can hopefully be dropped.
>
> One could argue that cc being != 0 is part of the test and so should go through report() and not assert().
> Which happens naturally, since the caller will likely compare it to some positive expected value.

Yes, I can also live with that if you change the commit message then :)

>>
>>> ---
>>>   lib/s390x/asm/arch_def.h | 5 +++--
>>>   1 file changed, 3 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/lib/s390x/asm/arch_def.h b/lib/s390x/asm/arch_def.h
>>> index 302ef1f..4167e2b 100644
>>> --- a/lib/s390x/asm/arch_def.h
>>> +++ b/lib/s390x/asm/arch_def.h
>>> @@ -334,7 +334,7 @@ static inline int stsi(void *addr, int fc, int sel1, int sel2)
>>>       return cc;
>>>   }
>>>   -static inline unsigned long stsi_get_fc(void)
>>> +static inline int stsi_get_fc(void)
>>>   {
>>>       register unsigned long r0 asm("0") = 0;
>>>       register unsigned long r1 asm("1") = 0;
>>> @@ -346,7 +346,8 @@ static inline unsigned long stsi_get_fc(void)
>>>                : "+d" (r0), [cc] "=d" (cc)
>>>                : "d" (r1)
>>>                : "cc", "memory");
>>> -    assert(!cc);
>>> +    if (cc != 0)
>>> +        return -1;
>>>       return r0 >> 28;
>>>   }
>>>
>>
>