lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <4fdc8cc0-0b04-4879-9337-9eda3b83f603@intel.com>
Date: Tue, 2 Jul 2024 14:26:25 -0700
From: Reinette Chatre <reinette.chatre@...el.com>
To: "Luck, Tony" <tony.luck@...el.com>, "Wieczor-Retman, Maciej"
	<maciej.wieczor-retman@...el.com>, "shuah@...nel.org" <shuah@...nel.org>,
	"Yu, Fenghua" <fenghua.yu@...el.com>
CC: "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

Hi Tony,

On 7/1/24 9:04 AM, 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.
> 
> +	if (fscanf(fp, "%s", offline_cpus_str) < 0) {
> 
> fscanf() seems like a heavy hammer.

Do you perhaps have any recommendations that should be used instead of
fscanf()? I checked with stat() but could not see a difference between
file with a CPU and a file without. Other alternative is
open()/read()/close()? Looks like when there are no offline CPUs then
the file will only contain '\n' so it may be possible to read one byte
from the file and confirm it is '\n' as a check for "cpus_offline_empty()".

Reinette

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ