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

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

 



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




[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