diff mbox series

[7/7] multipathd: only grab conf once for filter_path()

Message ID 20181023220552.1306-8-mwilck@suse.com (mailing list archive)
State Not Applicable, archived
Delegated to: christophe varoqui
Headers show
Series multipathd: make uxlsnr errors really fatal | expand

Commit Message

Martin Wilck Oct. 23, 2018, 10:05 p.m. UTC
This saves a possibly large number of cleanup push/pop calls and
slightly improves readability.

Signed-off-by: Martin Wilck <mwilck@suse.com>
---
 multipathd/main.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

Comments

Benjamin Marzinski Oct. 26, 2018, 8:50 p.m. UTC | #1
On Wed, Oct 24, 2018 at 12:05:52AM +0200, Martin Wilck wrote:
> This saves a possibly large number of cleanup push/pop calls and
> slightly improves readability.
> 

Reviewed-by: Benjamin Marzinsk <bmarzins@redhat.com>

> Signed-off-by: Martin Wilck <mwilck@suse.com>
> ---
>  multipathd/main.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/multipathd/main.c b/multipathd/main.c
> index 768da8da..a7cd3b09 100644
> --- a/multipathd/main.c
> +++ b/multipathd/main.c
> @@ -2332,16 +2332,17 @@ configure (struct vectors * vecs)
>  		goto fail;
>  	}
>  
> +	conf = get_multipath_config();
> +	pthread_cleanup_push(put_multipath_config, conf);
>  	vector_foreach_slot (vecs->pathvec, pp, i){
> -		conf = get_multipath_config();
> -		pthread_cleanup_push(put_multipath_config, conf);
>  		if (filter_path(conf, pp) > 0){
>  			vector_del_slot(vecs->pathvec, i);
>  			free_path(pp);
>  			i--;
>  		}
> -		pthread_cleanup_pop(1);
>  	}
> +	pthread_cleanup_pop(1);
> +
>  	if (map_discovery(vecs)) {
>  		condlog(0, "configure failed at map discovery");
>  		goto fail;
> -- 
> 2.19.1

--
dm-devel mailing list
dm-devel@redhat.com
https://www.redhat.com/mailman/listinfo/dm-devel
diff mbox series

Patch

diff --git a/multipathd/main.c b/multipathd/main.c
index 768da8da..a7cd3b09 100644
--- a/multipathd/main.c
+++ b/multipathd/main.c
@@ -2332,16 +2332,17 @@  configure (struct vectors * vecs)
 		goto fail;
 	}
 
+	conf = get_multipath_config();
+	pthread_cleanup_push(put_multipath_config, conf);
 	vector_foreach_slot (vecs->pathvec, pp, i){
-		conf = get_multipath_config();
-		pthread_cleanup_push(put_multipath_config, conf);
 		if (filter_path(conf, pp) > 0){
 			vector_del_slot(vecs->pathvec, i);
 			free_path(pp);
 			i--;
 		}
-		pthread_cleanup_pop(1);
 	}
+	pthread_cleanup_pop(1);
+
 	if (map_discovery(vecs)) {
 		condlog(0, "configure failed at map discovery");
 		goto fail;