From: Christian Brauner Date: Mon, 9 Aug 2021 13:59:26 +0000 (+0200) Subject: lsm/apparmor: use cleanup macro X-Git-Tag: lxc-5.0.0~122^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a36e286bea5f34be9689ff0353dcfa7f893c0ddd;p=thirdparty%2Flxc.git lsm/apparmor: use cleanup macro Signed-off-by: Christian Brauner --- diff --git a/src/lxc/lsm/apparmor.c b/src/lxc/lsm/apparmor.c index 6bf6c6eea..a0d81ea01 100644 --- a/src/lxc/lsm/apparmor.c +++ b/src/lxc/lsm/apparmor.c @@ -611,8 +611,8 @@ out: static bool file_is_yes(const char *path) { + __do_close int fd = -EBADF; ssize_t rd; - int fd; char buf[8]; /* we actually just expect "yes" or "no" */ fd = open(path, O_RDONLY | O_CLOEXEC); @@ -620,7 +620,6 @@ static bool file_is_yes(const char *path) return false; rd = lxc_read_nointr(fd, buf, sizeof(buf)); - close(fd); return rd >= 4 && strnequal(buf, "yes\n", 4); }