[PATCH v3 3/3] statvfs: f_type: NEWS & test

Adhemerval Zanella Netto adhemerval.zanella@linaro.org
Tue Aug 15 12:48:04 GMT 2023



On 15/08/23 09:41, Florian Weimer wrote:
> * Adhemerval Zanella Netto:
> 
>>> This fails with certain file systems because the types of f_type differ
>>> in signedness:
>>>
>>> =====FAIL: io/tst-statvfs.out=====
>>> tst-statvfs.c:19: numeric comparison failure
>>>    left: 2435016766 (0x9123683e); from: st.f_type
>>>   right: -1859950530 (0x9123683e); from: stf.f_type
>>> /builddir/build/BUILD/glibc-2.38.9000-40-gd6fe19facc/build-i686-redhat-linux/io/
>>> tst-statvfs: free: 53658025, mandatory: no, tp=9123683e
>>> tst-statvfs.c:19: numeric comparison failure
>>>    left: 2435016766 (0x9123683e); from: st.f_type
>>>   right: -1859950530 (0x9123683e); from: stf.f_type
>>> tst-statvfs.c: free: 53658025, mandatory: no, tp=9123683e
>>> tst-statvfs.c:19: numeric comparison failure
>>>    left: 2435016766 (0x9123683e); from: st.f_type
>>>   right: -1859950530 (0x9123683e); from: stf.f_type
>>> /tmp: free: 53658025, mandatory: no, tp=9123683e
>>> error: 3 test failures
>>
>> Maybe add a TEST_COMPARE_NO_SIGN? The cast is always an option.
> 
> Or change the type of the new field to match the old field?

We discussed this briefly [1] on why Ahelenia decided to use an
unsigned type.  We still can change it, I don't have a strong
opinion here.

> 
> Due to the way TEST_COMPARE works, a no-sign option does not make much
> sense, I'm afraid.  It's supposed to compare the mathematical values
> regardless of type sizes.  If we want to accept certain signed vs
> unsigned mismatches as valid, I think we need to use a common size, at
> which point we might as well use a cast.
> 
> Conceptually, this should be close to what we want:
> 
>   if (st.f_type != stf.f_type)
>     TEST_COMPARE (st.f_type, stf.f_type);
> 
> Except that I expect it to produce a compiler warning about signedness
> mismatch.  So yes, I think we're going to have to add a cast.
> 
> Thanks,
> Florian
> 

[1] https://sourceware.org/pipermail/libc-alpha/2023-July/150308.html


More information about the Libc-alpha mailing list