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

From: Luck, Tony
Date: Mon Jul 01 2024 - 12:04:31 EST


+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;
+}