There are two functions (lxcProcHostRead() and
lxcProcReadMeminfo()) that could benefit from automatic file
closing.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
size_t size,
off_t offset)
{
- int fd;
+ VIR_AUTOCLOSE fd = -1;
int res;
fd = open(path, O_RDONLY);
if ((res = pread(fd, buf, size, offset)) < 0)
res = -errno;
- VIR_FORCE_CLOSE(fd);
return res;
}
off_t offset)
{
int res;
- FILE *fp = NULL;
+ g_autoptr(FILE) fp = NULL;
g_autofree char *line = NULL;
size_t n;
struct virLXCMeminfo meminfo;
memcpy(buf, virBufferCurrentContent(new_meminfo), res);
cleanup:
- VIR_FORCE_FCLOSE(fp);
return res;
}