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

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

 



+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.

	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).

+			fclose(fp);
+			return 1;

			return true;

+		}
+		ksft_perror("Could not read offline CPUs file!");
+	}
+
+	fclose(fp);
+
+	return 0;

	return false;
+}






[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