[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <evds3zyrwl3tgs7l6ppcg3bnvlxaewcetacuppek4uevx5i7lb@rj7ciugpp5u3>
Date: Wed, 3 Jul 2024 08:50:27 +0200
From: Maciej Wieczor-Retman <maciej.wieczor-retman@...el.com>
To: "Luck, Tony" <tony.luck@...el.com>
CC: "shuah@...nel.org" <shuah@...nel.org>, "Chatre, Reinette"
<reinette.chatre@...el.com>, "Yu, Fenghua" <fenghua.yu@...el.com>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"linux-kselftest@...r.kernel.org" <linux-kselftest@...r.kernel.org>,
"ilpo.jarvinen@...ux.intel.com" <ilpo.jarvinen@...ux.intel.com>
Subject: Re: [PATCH v3 2/2] selftests/resctrl: Adjust SNC support messages
Thanks for the review,
On 2024-07-01 at 18:04:00 +0200, Luck, Tony wrote:
>+static bool cpus_offline_empty(void)
>+{
>+ char offline_cpus_str[64];
>+ FILE *fp;
>+
>+ fp = fopen("/sys/devices/system/cpu/offline", "r");
>
>Check for fp == NULL before using it.
Thanks, will add it.
>
>+ if (fscanf(fp, "%s", offline_cpus_str) < 0) {
>
>fscanf() seems like a heavy hammer.
>
> if (fgets(offline_cpus_str, sizeof(offline_cpus_str), fp) == NULL) {
>+ if (!errno) {
>
>Don't need an errno check (seems dubious mixing errno with stdio).
fscanf() returns "-1" when nothing was read as well as if there was an error.
But when nothing was read the errno is "0" instead of some error code so I could
differentiate the cases that way. The fgetc() you settled on shouldn't have this
problem.
>
>+ fclose(fp);
>+ return 1;
>
> return true;
>
>+ }
>+ ksft_perror("Could not read offline CPUs file!");
>+ }
>+
>+ fclose(fp);
>+
>+ return 0;
>
> return false;
>+}
>
--
Kind regards
Maciej Wieczór-Retman
Powered by blists - more mailing lists