multipathd: only grab conf once for filter_path()
authorMartin Wilck <mwilck@suse.com>
Fri, 2 Nov 2018 12:24:02 +0000 (13:24 +0100)
committerChristophe Varoqui <christophe.varoqui@opensvc.com>
Wed, 14 Nov 2018 07:22:30 +0000 (08:22 +0100)
This saves a possibly large number of cleanup push/pop calls and
slightly improves readability.

Reviewed-by: Benjamin Marzinski <bmarzins@redhat.com>
Signed-off-by: Martin Wilck <mwilck@suse.com>
multipathd/main.c

index 3cccc9f..a445b05 100644 (file)
@@ -2340,16 +2340,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;