summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHarald Hoyer <harald@redhat.com>2013-03-07 08:52:56 +0100
committerLennart Poettering <lennart@poettering.net>2013-03-07 16:09:27 +0100
commit57dbefdf3878cf3408f62beb69f4b87b5dc65df2 (patch)
treed0dc051ad14ea3953870fe689813644c6ca8558d
parentb9a496c166c35f670b1f0fce8745bc5df5ea74ad (diff)
bootchart: use _cleanup_fclose_
-rw-r--r--src/bootchart/log.c12
1 files changed, 4 insertions, 8 deletions
diff --git a/src/bootchart/log.c b/src/bootchart/log.c
index 43999f23cf..ccec03f12c 100644
--- a/src/bootchart/log.c
+++ b/src/bootchart/log.c
@@ -57,7 +57,7 @@ double gettime_ns(void)
void log_uptime(void)
{
- FILE *f;
+ FILE _cleanup_fclose_ *f = NULL;
char str[32];
double uptime;
@@ -65,11 +65,9 @@ void log_uptime(void)
if (!f)
return;
- if (!fscanf(f, "%s %*s", str)) {
- fclose(f);
+ if (!fscanf(f, "%s %*s", str))
return;
- }
- fclose(f);
+
uptime = strtod(str, NULL);
log_start = gettime_ns();
@@ -120,7 +118,6 @@ void log_sample(int sample)
{
static int vmstat;
static int schedstat;
- FILE *st;
char buf[4095];
char key[256];
char val[256];
@@ -253,6 +250,7 @@ schedstat_next:
/* end of our LL? then append a new record */
if (ps->pid != pid) {
+ FILE _cleanup_fclose_ *st = NULL;
char t[32];
struct ps_struct *parent;
@@ -320,10 +318,8 @@ schedstat_next:
if (!st)
continue;
if (!fscanf(st, "%*s %*s %*s %i", &p)) {
- fclose(st);
continue;
}
- fclose(st);
ps->ppid = p;
/*