summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/bootchart/svg.c6
-rw-r--r--src/shared/macro.h1
-rw-r--r--src/shared/util.c5
-rw-r--r--src/shared/util.h1
4 files changed, 10 insertions, 3 deletions
diff --git a/src/bootchart/svg.c b/src/bootchart/svg.c
index 156918a94b..b9636e20a3 100644
--- a/src/bootchart/svg.c
+++ b/src/bootchart/svg.c
@@ -22,6 +22,8 @@
#include <sys/utsname.h>
#include "bootchart.h"
+#include "util.h"
+#include "macro.h"
#define time_to_graph(t) ((t) * scale_x)
@@ -702,7 +704,7 @@ static int ps_filter(struct ps_struct *ps)
static void svg_do_initcall(int count_only)
{
- FILE *f;
+ FILE _cleanup_pclose_ *f = NULL;
double t;
char func[256];
int ret;
@@ -787,8 +789,6 @@ static void svg_do_initcall(int count_only)
kcount++;
}
-
- fclose(f);
}
diff --git a/src/shared/macro.h b/src/shared/macro.h
index 29d91392f8..b307dedaa8 100644
--- a/src/shared/macro.h
+++ b/src/shared/macro.h
@@ -196,6 +196,7 @@ static inline size_t IOVEC_INCREMENT(struct iovec *i, unsigned n, size_t k) {
#define _cleanup_free_ __attribute__((cleanup(freep)))
#define _cleanup_fclose_ __attribute__((cleanup(fclosep)))
+#define _cleanup_pclose_ __attribute__((cleanup(pclosep)))
#define _cleanup_close_ __attribute__((cleanup(closep)))
#define _cleanup_closedir_ __attribute__((cleanup(closedirp)))
#define _cleanup_umask_ __attribute__((cleanup(umaskp)))
diff --git a/src/shared/util.c b/src/shared/util.c
index 490399c910..969ef2bb90 100644
--- a/src/shared/util.c
+++ b/src/shared/util.c
@@ -5553,6 +5553,11 @@ void fclosep(FILE **f) {
fclose(*f);
}
+void pclosep(FILE **f) {
+ if (*f)
+ pclose(*f);
+}
+
void closep(int *fd) {
if (*fd >= 0)
close_nointr_nofail(*fd);
diff --git a/src/shared/util.h b/src/shared/util.h
index 202e15d481..223617c3ff 100644
--- a/src/shared/util.h
+++ b/src/shared/util.h
@@ -522,6 +522,7 @@ int get_home_dir(char **ret);
void freep(void *p);
void fclosep(FILE **f);
+void pclosep(FILE **f);
void closep(int *fd);
void closedirp(DIR **d);
void umaskp(mode_t *u);