From 6dce80c533df445c7926e952387edd59209ff3ee Mon Sep 17 00:00:00 2001 From: Adrian Reber Date: Thu, 16 Jan 2025 07:52:42 +0000 Subject: [PATCH] util: added cleanup_file attribute. Signed-off-by: Adrian Reber --- criu/include/util.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/criu/include/util.h b/criu/include/util.h index ae293a68c..4793f7f20 100644 --- a/criu/include/util.h +++ b/criu/include/util.h @@ -406,6 +406,14 @@ static inline void cleanup_freep(void *p) free(*pp); } +#define cleanup_file __attribute__((cleanup(cleanup_filep))) +static inline void cleanup_filep(FILE **f) +{ + FILE *file = *f; + if (file) + (void)fclose(file); +} + extern int run_command(char *buf, size_t buf_size, int (*child_fn)(void *), void *args); /*