[PATCH v3 4/7] selftests/powerpc: Add read/write debugfs file, int

Andrew Donnellan ajd at linux.ibm.com
Wed Jan 25 15:59:56 AEDT 2023


On Mon, 2022-11-28 at 15:19 +1100, Benjamin Gray wrote:
> Debugfs files are not always integers, so make *_file return/write a
> byte buffer, and *_int deal with int values specifically. This
> increases
> consistency with the other file read/write helpers.
> 
> Signed-off-by: Benjamin Gray <bgray at linux.ibm.com>

This seems like a sensible idea.

Nitpick below, otherwise it looks like you have changed over all 21
call sites and the new helpers look better.

Reviewed-by: Andrew Donnellan <ajd at linux.ibm.com>

> -int read_debugfs_file(char *debugfs_file, int *result)
> +int read_debugfs_int(const char *debugfs_file, int *result)
>  {
>         int err;
> -       char path[PATH_MAX];
>         char value[16] = {0};
>  
> -       strcpy(path, "/sys/kernel/debug/");
> -       strncat(path, debugfs_file, PATH_MAX - strlen(path) - 1);
> -
> -       if ((err = read_file(path, value, sizeof(value) - 1, NULL)))
> +       if ((err = read_debugfs_file(debugfs_file, value,
> sizeof(value) - 1)))

Per my comments on the previous patch, separate the function call from
the error check

-- 
Andrew Donnellan    OzLabs, ADL Canberra
ajd at linux.ibm.com   IBM Australia Limited


More information about the Linuxppc-dev mailing list