commit: 06d24881ff95c0eca6945420675e0ab953fa43d3
Author: Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Tue May 14 20:15:13 2019 +0000
Commit: Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Tue May 14 20:15:13 2019 +0000
URL: https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=06d24881
libq/tree: cleanup tree_pkg_vdb_eat a little
Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>
libq/tree.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/libq/tree.c b/libq/tree.c
index 0659426..17f51fc 100644
--- a/libq/tree.c
+++ b/libq/tree.c
@@ -497,9 +497,14 @@ tree_pkg_vdb_eat(
char **bufptr,
size_t *buflen)
{
- int fd = tree_pkg_vdb_openat(pkg_ctx, file, O_RDONLY, 0);
- bool ret = eat_file_fd(fd, bufptr, buflen);
- rmspace(*bufptr);
+ int fd;
+ bool ret;
+
+ fd = tree_pkg_vdb_openat(pkg_ctx, file, O_RDONLY, 0);
+ ret = eat_file_fd(fd, bufptr, buflen);
+ if (ret)
+ rmspace(*bufptr);
+
if (fd != -1)
close(fd);
return ret;