[Rpm-ecosystem] [PATCH v6 01/11] Refactor copyFile to not close files

Lubos Kardos lkardos at redhat.com
Thu Jul 16 14:10:44 UTC 2015


Hi,
copyFile() opens those files with manageFile(), if they are not already open.
But copyFile() is called just once and arguments are open files so we probably
can remove calling of manageFile() from copyFile() too.

----- Original Message -----
> From: "Mimi Zohar" <zohar at linux.vnet.ibm.com>
> To: rpm-ecosystem at lists.rpm.org
> Cc: fin at linux.vnet.ibm.com, "Fionnuala Gunter" <fionnuala.gunter at gmail.com>
> Sent: Monday, July 6, 2015 8:52:15 PM
> Subject: [Rpm-ecosystem] [PATCH v6 01/11] Refactor copyFile to not close	files
> 
> 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.
> ---
>  sign/rpmgensig.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/sign/rpmgensig.c b/sign/rpmgensig.c
> index 24bf39e..cf79a87 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)
> @@ -184,8 +188,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.1.0
> 
> _______________________________________________
> Rpm-ecosystem mailing list
> Rpm-ecosystem at lists.rpm.org
> http://lists.rpm.org/mailman/listinfo/rpm-ecosystem
> 

Lubos


More information about the Rpm-ecosystem mailing list