chiark / gitweb /
networkctl: port from libudev to sd-device
[elogind.git] / src / bootchart / svg.c
index 93b4764ee736fc28b9b7fe30b06acf0f03d83bff..54129159accdf7117b6d88e1acfb7dc45b3b0d53 100644 (file)
@@ -170,6 +170,9 @@ static void svg_title(const char *build) {
                 if (!fgets(cmdline, 255, f))
                         sprintf(cmdline, "Unknown");
                 fclose(f);
+        } else {
+                if (fd >= 0)
+                        close(fd);
         }
 
         /* extract root fs so we can find disk model name in sysfs */
@@ -185,6 +188,9 @@ static void svg_title(const char *build) {
                         if (!fgets(model, 255, f))
                                 fprintf(stderr, "Error reading disk model for %s\n", rootbdev);
                         fclose(f);
+                } else {
+                        if (fd >= 0)
+                                close(fd);
                 }
         }
 
@@ -208,6 +214,9 @@ static void svg_title(const char *build) {
                         }
                 }
                 fclose(f);
+        } else {
+                if (fd >= 0)
+                        close(fd);
         }
 
         svg("<text class=\"t1\" x=\"0\" y=\"30\">Bootchart for %s - %s</text>\n",
@@ -1167,7 +1176,7 @@ static void svg_ps_bars(void) {
 
                 ps->sample = ps->sample->next;
                 sample_hz = ps->sample;
-                for (ii=0;((ii<(int)arg_hz/2)&&(ps->sample->next));ii++)
+                for (ii=0;((ii<(int)arg_hz/2)&&(sample_hz->next));ii++)
                         sample_hz = sample_hz->next;
 
                 /* subtract bootchart cpu utilization from total */