Re: [PATCH v3 2/2] selftests/resctrl: Adjust SNC support messages

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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




[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux