diff mbox series

[14/21] libmultipath: update_bindings_file: take filename argument

Message ID 20230901180235.23980-15-mwilck@suse.com (mailing list archive)
State Not Applicable, archived
Delegated to: christophe varoqui
Headers show
Series multipath-tools: user-friendly names rework | expand

Commit Message

Martin Wilck Sept. 1, 2023, 6:02 p.m. UTC
From: Martin Wilck <mwilck@suse.com>

This function just uses the file name, no other configuration
parameters. Also, pass the Bindings argument first to use the
same convention as the other functions in this file.

Signed-off-by: Martin Wilck <mwilck@suse.com>
---
 libmultipath/alias.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

Comments

Benjamin Marzinski Sept. 6, 2023, 10:45 p.m. UTC | #1
On Fri, Sep 01, 2023 at 08:02:27PM +0200, mwilck@suse.com wrote:
> From: Martin Wilck <mwilck@suse.com>
> 
> This function just uses the file name, no other configuration
> parameters. Also, pass the Bindings argument first to use the
> same convention as the other functions in this file.
> 
Reviewed-by: Benjamin Marzinski <bmarzins@redhat.com>
> Signed-off-by: Martin Wilck <mwilck@suse.com>
> ---
>  libmultipath/alias.c | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/libmultipath/alias.c b/libmultipath/alias.c
> index 5a6cdee..76d852f 100644
> --- a/libmultipath/alias.c
> +++ b/libmultipath/alias.c
> @@ -138,15 +138,15 @@ static int write_bindings_file(const Bindings *bindings, int fd)
>  	return 0;
>  }
>  
> -static int update_bindings_file(const struct config *conf,
> -				const Bindings *bindings)
> +static int update_bindings_file(const Bindings *bindings,
> +				const char *bindings_file)
>  {
>  	int rc;
>  	int fd = -1;
>  	char tempname[PATH_MAX];
>  	mode_t old_umask;
>  
> -	if (safe_sprintf(tempname, "%s.XXXXXX", conf->bindings_file))
> +	if (safe_sprintf(tempname, "%s.XXXXXX", bindings_file))
>  		return -1;
>  	/* coverity: SECURE_TEMP */
>  	old_umask = umask(0077);
> @@ -164,10 +164,10 @@ static int update_bindings_file(const struct config *conf,
>  		unlink(tempname);
>  		return rc;
>  	}
> -	if ((rc = rename(tempname, conf->bindings_file)) == -1)
> +	if ((rc = rename(tempname, bindings_file)) == -1)
>  		condlog(0, "%s: rename: %m", __func__);
>  	else
> -		condlog(1, "updated bindings file %s", conf->bindings_file);
> +		condlog(1, "updated bindings file %s", bindings_file);
>  	return rc;
>  }
>  
> @@ -778,7 +778,7 @@ int check_alias_settings(const struct config *conf)
>  			rc = _check_bindings_file(conf, file, &bindings);
>  			pthread_cleanup_pop(1);
>  			if (rc == -1 && can_write && !conf->bindings_read_only)
> -				rc = update_bindings_file(conf, &bindings);
> +				rc = update_bindings_file(&bindings, conf->bindings_file);
>  			else if (rc == -1)
>  				condlog(0, "ERROR: bad settings in read-only bindings file %s",
>  					conf->bindings_file);
> -- 
> 2.41.0
--
dm-devel mailing list
dm-devel@redhat.com
https://listman.redhat.com/mailman/listinfo/dm-devel
diff mbox series

Patch

diff --git a/libmultipath/alias.c b/libmultipath/alias.c
index 5a6cdee..76d852f 100644
--- a/libmultipath/alias.c
+++ b/libmultipath/alias.c
@@ -138,15 +138,15 @@  static int write_bindings_file(const Bindings *bindings, int fd)
 	return 0;
 }
 
-static int update_bindings_file(const struct config *conf,
-				const Bindings *bindings)
+static int update_bindings_file(const Bindings *bindings,
+				const char *bindings_file)
 {
 	int rc;
 	int fd = -1;
 	char tempname[PATH_MAX];
 	mode_t old_umask;
 
-	if (safe_sprintf(tempname, "%s.XXXXXX", conf->bindings_file))
+	if (safe_sprintf(tempname, "%s.XXXXXX", bindings_file))
 		return -1;
 	/* coverity: SECURE_TEMP */
 	old_umask = umask(0077);
@@ -164,10 +164,10 @@  static int update_bindings_file(const struct config *conf,
 		unlink(tempname);
 		return rc;
 	}
-	if ((rc = rename(tempname, conf->bindings_file)) == -1)
+	if ((rc = rename(tempname, bindings_file)) == -1)
 		condlog(0, "%s: rename: %m", __func__);
 	else
-		condlog(1, "updated bindings file %s", conf->bindings_file);
+		condlog(1, "updated bindings file %s", bindings_file);
 	return rc;
 }
 
@@ -778,7 +778,7 @@  int check_alias_settings(const struct config *conf)
 			rc = _check_bindings_file(conf, file, &bindings);
 			pthread_cleanup_pop(1);
 			if (rc == -1 && can_write && !conf->bindings_read_only)
-				rc = update_bindings_file(conf, &bindings);
+				rc = update_bindings_file(&bindings, conf->bindings_file);
 			else if (rc == -1)
 				condlog(0, "ERROR: bad settings in read-only bindings file %s",
 					conf->bindings_file);