From 0e75556d1e40b96b9e57eed42117a72b11bdb945 Mon Sep 17 00:00:00 2001 From: Christophe Varoqui Date: Wed, 26 Oct 2005 11:07:54 +0200 Subject: [PATCH] [multipath] get_refwwid() tweaking - don't recode strdup() everywhere - get_user_friendly_wwid() does allocate, not need to strdup() again. This was a leak proper --- multipath/main.c | 30 +++++++++--------------------- 1 file changed, 9 insertions(+), 21 deletions(-) diff --git a/multipath/main.c b/multipath/main.c index 7090ee9..7808983 100644 --- a/multipath/main.c +++ b/multipath/main.c @@ -84,14 +84,7 @@ get_refwwid (vector pathvec) return NULL; } } - - refwwid = MALLOC(WWID_SIZE); - - if (!refwwid) - return NULL; - - memcpy(refwwid, pp->wwid, WWID_SIZE); - return refwwid; + return STRDUP(pp->wwid); } if (conf->dev_type == DEV_DEVT) { @@ -117,27 +110,22 @@ get_refwwid (vector pathvec) return NULL; } } - - refwwid = MALLOC(WWID_SIZE); - - if (!refwwid) - return NULL; - - memcpy(refwwid, pp->wwid, WWID_SIZE); - return refwwid; + return STRDUP(pp->wwid); } if (conf->dev_type == DEV_DEVMAP) { condlog(3, "limited scope = %s", conf->dev); /* - * may be an alias + * may be a binding */ - refwwid = get_mpe_wwid(conf->dev); + refwwid = get_user_friendly_wwid(conf->dev); + + if (refwwid) + return refwwid; /* - * or a binding + * or may be an alias */ - if (!refwwid) - refwwid = get_user_friendly_wwid(conf->dev); + refwwid = get_mpe_wwid(conf->dev); /* * or directly a wwid -- 2.7.4