[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <53812f86-beb3-4f7e-ba9a-6bf0f0340426@intel.com>
Date: Tue, 28 Nov 2023 14:22:11 -0800
From: Reinette Chatre <reinette.chatre@...el.com>
To: Ilpo Järvinen <ilpo.jarvinen@...ux.intel.com>,
<linux-kselftest@...r.kernel.org>, Shuah Khan <shuah@...nel.org>,
"Shaopeng Tan" <tan.shaopeng@...fujitsu.com>,
Maciej Wieczór-Retman
<maciej.wieczor-retman@...el.com>,
Fenghua Yu <fenghua.yu@...el.com>
CC: <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v2 23/26] selftests/resctrl: Add helper to convert L2/3 to
integer
Hi Ilpo,
On 11/20/2023 3:13 AM, Ilpo Järvinen wrote:
> "L2"/"L3" conversion to integer is embedded into get_cache_size()
> which prevents reuse.
>
> Create a helper for the cache string to integer conversion to make
> it reusable.
>
> Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@...ux.intel.com>
> ---
> tools/testing/selftests/resctrl/resctrlfs.c | 28 +++++++++++++++------
> 1 file changed, 20 insertions(+), 8 deletions(-)
>
> diff --git a/tools/testing/selftests/resctrl/resctrlfs.c b/tools/testing/selftests/resctrl/resctrlfs.c
> index fda5ad812faa..38ca3ae562e9 100644
> --- a/tools/testing/selftests/resctrl/resctrlfs.c
> +++ b/tools/testing/selftests/resctrl/resctrlfs.c
> @@ -94,6 +94,23 @@ int umount_resctrlfs(void)
> return 0;
> }
>
> +/*
> + * get_cache_level - Convert cache level from string to integer
> + * @cache_type: Cache level as string
> + *
> + * Return: cache level as integer or -1 if @cache_type is invalid.
> + */
> +static int get_cache_level(const char *cache_type)
> +{
> + if (!strcmp(cache_type, "L3"))
> + return 3;
> + if (!strcmp(cache_type, "L2"))
> + return 2;
> +
> + perror("Invalid cache level");
I know that you are just copying code here but this usage of
perror() does not look right. strcmp() does not set errno, it
does not "fail".
Reinette
Powered by blists - more mailing lists