[PATCH v3 3/3] statvfs: f_type: NEWS & test
Florian Weimer
fweimer@redhat.com
Tue Aug 15 12:41:56 GMT 2023
* 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?
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
More information about the Libc-alpha
mailing list