Add _cleanup_pclose_ and fix mismatching pipe close opened by popen()
Based-on-patch-by: Thomas Jarosch <thomas.jarosch@intra2net.com> cppcheck reported: [src/bootchart/svg.c:791]: (error) Mismatching allocation and deallocation: f
This commit is contained in:
@@ -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)))
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user