fix memory leak
[ardour.git] / tools / sanity_check / systemtest.cpp
index 0a8cae2d5f1db13a7f8f71ba327241470ff95af3..b7c04a203119058ab1cee220ccbab16d570f6e70 100644 (file)
@@ -108,27 +108,27 @@ int system_uses_frequencyscaling() {
   char filename[256], buf[256];
 
   while (!done) {
-    (void) snprintf(filename, 256, "/sys/devices/system/cpu/cpu%d/cpufreq/scaling_governor", cpu);
-    if (0<read_string(filename, buf, 256)) {
-      if ((0!=strcmp("performance", buf)) && 
-                                       (0!=strcmp("powersafe", buf))) {
-                               // So it's neither the "performance" nor the "powersafe" governor
-                               (void) snprintf(filename, 256, "/sys/devices/system/cpu/cpu%d/cpufreq/scaling_min_freq", cpu);
-                               if (read_int(filename, &min)) {
-                                       (void) snprintf(filename, 256, "/sys/devices/system/cpu/cpu%d/cpufreq/scaling_max_freq", cpu);
-                                       if (read_int(filename, &max)) {
-                                               if (min!=max) {
-                                                       // wrong governor AND different frequency limits -> scaling
-                                                       return 1;
-                                               }
-                                       
-                               }
-      }
-    } else {
-      // couldn't open file -> no more cores
-      done = 1;
-    }
-    cpu++;
+          (void) snprintf(filename, 256, "/sys/devices/system/cpu/cpu%d/cpufreq/scaling_governor", cpu);
+          if (0<read_string(filename, buf, 256)) {
+                  if ((0!=strncmp("performance", buf, 11)) && 
+                      (0!=strncmp("powersafe", buf, 9))) {
+                          // So it's neither the "performance" nor the "powersafe" governor
+                          (void) snprintf(filename, 256, "/sys/devices/system/cpu/cpu%d/cpufreq/scaling_min_freq", cpu);
+                          if (read_int(filename, &min)) {
+                                  (void) snprintf(filename, 256, "/sys/devices/system/cpu/cpu%d/cpufreq/scaling_max_freq", cpu);
+                                  if (read_int(filename, &max)) {
+                                          if (min!=max) {
+                                                  // wrong governor AND different frequency limits -> scaling
+                                                  return 1;
+                                          }
+                                  } 
+                          }
+                  }
+          } else {
+                  // couldn't open file -> no more cores
+                  done = 1;
+          }
+          cpu++;
   }
   
   // couldn't find anything that points to scaling
@@ -169,6 +169,7 @@ int system_user_in_group(const char *name) {
   gid = get_group_by_name(name);
   if (0==gid) {
     fprintf(stderr, "No %s group found\n", name);
+    free(list);
     return 0;
   }
   
@@ -249,13 +250,13 @@ int system_user_can_rtprio() {
 
   memset(&schparam, 0, sizeof(struct sched_param));
 
-  if (-1 == (min_prio = sched_get_priority_min(SCHED_RR))) {
+  if (-1 == (min_prio = sched_get_priority_min(SCHED_FIFO))) {
     perror("sched_get_priority");
     exit(EXIT_FAILURE);
   }
   schparam.sched_priority = min_prio;  
 
-  if (0 == sched_setscheduler(0, SCHED_RR, &schparam)) {
+  if (0 == sched_setscheduler(0, SCHED_FIFO, &schparam)) {
     // TODO: restore previous state
     schparam.sched_priority = 0;
     if (0 != sched_setscheduler(0, SCHED_OTHER, &schparam)) {
@@ -295,7 +296,7 @@ long long unsigned int system_available_physical_mem() {
        char buf[256];
        long long unsigned int res = 0;
 
-       if (0<read_string((char*)"/proc/meminfo", buf, sizeof (buf))) {
+       if (0<read_string(const_cast<char*>("/proc/meminfo"), buf, sizeof (buf))) {
                if (strncmp (buf, "MemTotal:", 9) == 0) {
                        if (sscanf (buf, "%*s %llu", &res) != 1) {
                                perror ("parse error in /proc/meminfo");