Re: [PATCH v4] lib/math: Add int_sqrt test suite

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

 



On Tue, 10 Dec 2024, Luis Felipe Hernandez wrote:

> On Tue, Dec 10, 2024 at 02:59:12PM -0500, Nicolas Pitre wrote:
> > This will fail on a 32-bit system where sizeof(long) == 32 and 
> > ULONG_MAX == 4294967295. (meaning the result would be 65535).
> 
> Thank you for taking the time to review my patch and for pointing out the issue with the ULONG_MAX test case. I failed to think about how a 32-bit system would treat ULONG_MAX == 4294967295.
> 
> To address this, I was thinking of updating the test case to use a large enough value that remains within the bounds of unsigned long for both 32-bit and 64-bit architectures instead. Specifically, 2147483648 (2^31), which has an integer square root of 46340. I believe this would ensure the test remains valid and portable across all supported architectures.
> 
> The updated test case would be as follows:
> { 2147483648, 46340, "large input"}

Sure.

And for such kind of test, more values to test is not a bad thing. So 
I'd suggest keeping { 4294967295, 65535 ] as well in the set as this 
represents a nice 
edge case.

It wouldn't hurt adding the entire set from 0 to 9 as well. Many 
different edge cases in that range.


Nicolas




[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux