From 5d26889a48c7532f9dbf2aca82e84524e913b02f Mon Sep 17 00:00:00 2001 From: Stefan Berger Date: Thu, 26 Oct 2017 19:53:43 -0400 Subject: Split off function wfd_close() to close a file (cherry picked from commit e276991614fd127f21aba94946f81f22cb7e6b73) --- lib/fsm.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/lib/fsm.c b/lib/fsm.c index c4164ad4d..24e79b40c 100644 --- a/lib/fsm.c +++ b/lib/fsm.c @@ -217,6 +217,16 @@ static int linkSane(FD_t wfd, const char *dest) sb.st_dev == lsb.st_dev && sb.st_ino == lsb.st_ino); } +static void wfd_close(FD_t *wfdp) +{ + if (wfdp && *wfdp) { + int myerrno = errno; + Fclose(*wfdp); + *wfdp = NULL; + errno = myerrno; + } +} + /** \ingroup payload * Create file from payload stream. * @return 0 on success @@ -246,11 +256,7 @@ static int expandRegular(rpmfi fi, const char *dest, rpmpsm psm, int exclusive, if (!nocontent) rc = rpmfiArchiveReadToFilePsm(fi, wfd, nodigest, psm); exit: - if (wfd) { - int myerrno = errno; - Fclose(wfd); - errno = myerrno; - } + wfd_close(&wfd); return rc; } -- cgit v1.2.1