On Wed, 27 May 2026 19:54:28 +0530, Sarthak Sharma <[email protected]>
wrote:
Hi Sarthak,
>
> diff --git a/tools/testing/selftests/mm/hugepage_settings.c
> b/tools/testing/selftests/mm/hugepage_settings.c
> index 2eab2110ac6a..c2f97fe97e58 100644
> --- a/tools/testing/selftests/mm/hugepage_settings.c
> +++ b/tools/testing/selftests/mm/hugepage_settings.c
> @@ -61,7 +62,9 @@ int thp_read_string(const char *name, const char * const
> strings[])
> exit(EXIT_FAILURE);
> }
>
> - if (!read_file(path, buf, sizeof(buf))) {
> + ret = read_file(path, buf, sizeof(buf));
> + if (ret < 0) {
> + errno = -ret;
> perror(path);
Hmm, looks like those slipped ksft conversion :/
For kselftest compatibility this should be
printf("# %s: %s (%d)\n", path, strerror(errno), errno);
> @@ -103,12 +106,18 @@ void thp_write_string(const char *name, const char *val)
> printf("%s: Pathname is too long\n", __func__);
> exit(EXIT_FAILURE);
> }
> - write_file(path, val, strlen(val) + 1);
> + ret = write_file(path, val, strlen(val) + 1);
> + if (ret < 0) {
> + errno = -ret;
> + perror(path);
> + exit(EXIT_FAILURE);
These seem to repeat themself, how about we move prints to read/write
helpers?
Then it wouldn't matter for the callers what the exact error was, and no
need for errno games.
>
> diff --git a/tools/testing/selftests/mm/vm_util.c
> b/tools/testing/selftests/mm/vm_util.c
> index 311fc5b4513e..290e5c29123e 100644
> --- a/tools/testing/selftests/mm/vm_util.c
> +++ b/tools/testing/selftests/mm/vm_util.c
> @@ -703,62 +703,72 @@ int read_file(const char *path, char *buf, size_t
> buflen)
> int fd;
> ssize_t numread;
>
> + if (buflen < 2)
> + return -EINVAL;
heh, this feels overly protective :)
--
Sincerely yours,
Mike.