Re: [PATCH v7 1/6] selftests/mm: make file helpers return errors

Sarthak Sharma <[email protected]>
Newsgroups org.kernel.vger.linux-doc,org.kernel.vger.linux-kernel,org.kernel.vger.linux-kselftest,org.kvack.linux-mm
Message-ID <[email protected]>
Hi David and Mark!

On 8/24/26 5:59 PM, David Hildenbrand (Arm) wrote:
> On 8/24/26 14:27, Mark Brown wrote:
>> On Mon, Aug 24, 2026 at 02:17:03PM +0200, David Hildenbrand (Arm) wrote:
>>> On 8/13/26 20:12, Sarthak Sharma wrote:
>>
>>>> +	if (buf[0] < '0' || buf[0] > '9')
>>>> +		return -EINVAL;
>>
>>> This is to reject any negative or hexadecimal numbers I assume?
>>
>> That won't reject hexidecimal - 0xNNNN matches the above.
> 
> Ugh, yes (and stuff starting without 0x would not be detected consistently).
> 

Yup, this is to reject anything that is not a digit. This check does not
reject hexadecimal values, but the strtoul(..., 10) stops at the x in
0xNNNN. Then the check

if (*end != '\0')
		return -EINVAL;

makes read_num() return -EINVAL.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.