There are two functions (lxcProcHostRead() and lxcProcReadMeminfo()) that could benefit from automatic file closing. Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx> --- src/lxc/lxc_fuse.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/lxc/lxc_fuse.c b/src/lxc/lxc_fuse.c index 9eff188d5f..1dedbc4069 100644 --- a/src/lxc/lxc_fuse.c +++ b/src/lxc/lxc_fuse.c @@ -126,7 +126,7 @@ lxcProcHostRead(char *path, size_t size, off_t offset) { - int fd; + VIR_AUTOCLOSE fd = -1; int res; fd = open(path, O_RDONLY); @@ -136,7 +136,6 @@ lxcProcHostRead(char *path, if ((res = pread(fd, buf, size, offset)) < 0) res = -errno; - VIR_FORCE_CLOSE(fd); return res; } @@ -148,7 +147,7 @@ lxcProcReadMeminfo(char *hostpath, off_t offset) { int res; - FILE *fp = NULL; + g_autoptr(FILE) fp = NULL; g_autofree char *line = NULL; size_t n; struct virLXCMeminfo meminfo; @@ -251,7 +250,6 @@ lxcProcReadMeminfo(char *hostpath, memcpy(buf, virBufferCurrentContent(new_meminfo), res); cleanup: - VIR_FORCE_FCLOSE(fp); return res; } -- 2.34.1