[Rpm-maint] [PATCH v9 01/13] Refactor copyFile to not close files

Fionnuala Gunter fionnuala.gunter at gmail.com
Tue Jul 21 17:00:35 UTC 2015


From: "fin at linux.vnet.ibm.com" <fin at linux.vnet.ibm.com>

This patch refactors copyFile so that it doesn't close sfdp and tfdp,
since copyFile didn't open those files. Also, the caller to copyFile
closes these files. This patch also adds descriptions of copyFile
parameters.

Changelog:
- removed call to manageFile() since copyFile() arguments are open files
---
 sign/rpmgensig.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/sign/rpmgensig.c b/sign/rpmgensig.c
index 24bf39e..09a5858 100644
--- a/sign/rpmgensig.c
+++ b/sign/rpmgensig.c
@@ -151,6 +151,10 @@ static int manageFile(FD_t *fdp, const char *fn, int flags)
 
 /**
  * Copy header+payload, calculating digest(s) on the fly.
+ * @param sfdp source file
+ * @param sfnp source path
+ * @param tfdp destination file
+ * @param tfnp destination path
  */
 static int copyFile(FD_t *sfdp, const char *sfnp,
 		FD_t *tfdp, const char *tfnp)
@@ -159,11 +163,6 @@ static int copyFile(FD_t *sfdp, const char *sfnp,
     ssize_t count;
     int rc = 1;
 
-    if (manageFile(sfdp, sfnp, O_RDONLY))
-	goto exit;
-    if (manageFile(tfdp, tfnp, O_WRONLY|O_CREAT|O_TRUNC))
-	goto exit;
-
     while ((count = Fread(buf, sizeof(buf[0]), sizeof(buf), *sfdp)) > 0)
     {
 	if (Fwrite(buf, sizeof(buf[0]), count, *tfdp) != count) {
@@ -184,8 +183,6 @@ static int copyFile(FD_t *sfdp, const char *sfnp,
     rc = 0;
 
 exit:
-    if (*sfdp)	(void) closeFile(sfdp);
-    if (*tfdp)	(void) closeFile(tfdp);
     return rc;
 }
 
-- 
2.4.3



More information about the Rpm-maint mailing list