diff options
author | Benjamin Gray <bgray@linux.ibm.com> | 2023-02-03 11:39:45 +1100 |
---|---|---|
committer | Michael Ellerman <mpe@ellerman.id.au> | 2023-02-09 23:56:45 +1100 |
commit | d1bc05b7bf02f8635fe6c445f67d78f85234cbb7 (patch) | |
tree | 85d9bd4f50840b97852992c69db196f6120e51f0 /tools/testing/selftests/powerpc/dscr/dscr_sysfs_test.c | |
parent | 121d340be9a17ed89d523c56203908c01e09a306 (diff) | |
download | lwn-d1bc05b7bf02f8635fe6c445f67d78f85234cbb7.tar.gz lwn-d1bc05b7bf02f8635fe6c445f67d78f85234cbb7.zip |
selftests/powerpc: Parse long/unsigned long value safely
Often a file is expected to hold an integral value. Existing functions
will use a C stdlib function like atoi or strtol to parse the file.
These operations are error prone, with complicated error conditions
(atoi returns 0 if not a number, and is undefined behaviour if not in
range. strtol returns 0 if not a number, and LONG_MIN/MAX if not in
range + sets errno to ERANGE).
Signed-off-by: Benjamin Gray <bgray@linux.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20230203003947.38033-4-bgray@linux.ibm.com
Diffstat (limited to 'tools/testing/selftests/powerpc/dscr/dscr_sysfs_test.c')
0 files changed, 0 insertions, 0 deletions