On 5/30/25 8:43 PM, Jeffrey E Altman wrote:
On 5/30/2025 6:29 AM, Su Hui wrote:
On 5/30/25 7:35 AM, Jeffrey E Altman wrote:
Do you see an overflow condition which would not be caught by those
checks which would be caught by use of kstrtoul()?
Actually, no example in reality.
If p can equal to '0xffffffffffffffff0000000000000001',
simple_strtoul() and kstroul() all transform 'p' to unsigned long
value '0x1'.
But kstrtoul() return an error and we can know overflow happens. If
'p' can be a very long string, kstroul() make sense.
The expected use case is for the input string not to exceed 3
characters. The valid range is decimal 0 to 128. That could be
enforced by switching to simple_strntoul() and relying upon the
existing checks.
Got it, thanks for your reply and sorry for the noise.
Su Hui