dm-devel.redhat.com archive mirror
 help / color / mirror / Atom feed
From: Benjamin Marzinski <bmarzins@redhat.com>
To: Christophe Varoqui <christophe.varoqui@opensvc.com>
Cc: device-mapper development <dm-devel@redhat.com>,
	Martin Wilck <Martin.Wilck@suse.com>
Subject: [dm-devel] [PATCH V2 02/11] libmultipath: don't copy pgpolicy string in get_pgpolicy_name
Date: Tue,  6 Jun 2023 15:13:02 -0500	[thread overview]
Message-ID: <1686082391-29210-3-git-send-email-bmarzins@redhat.com> (raw)
In-Reply-To: <1686082391-29210-1-git-send-email-bmarzins@redhat.com>

copying the value into a passed in buffer doesn't help any of the
callers of this function. It's just wasted work.

Reviewed-by: Martin Wilck <mwilck@suse.com>
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
---
 libmultipath/dict.c       |  6 +-----
 libmultipath/pgpolicies.c | 27 ++++++++-------------------
 libmultipath/pgpolicies.h |  2 +-
 libmultipath/propsel.c    |  6 ++----
 4 files changed, 12 insertions(+), 29 deletions(-)

diff --git a/libmultipath/dict.c b/libmultipath/dict.c
index 2e9b45f9..dddd3cd6 100644
--- a/libmultipath/dict.c
+++ b/libmultipath/dict.c
@@ -1209,14 +1209,10 @@ set_pgpolicy(vector strvec, void *ptr, const char *file, int line_nr)
 int
 print_pgpolicy(struct strbuf *buff, long pgpolicy)
 {
-	char str[POLICY_NAME_SIZE];
-
 	if (!pgpolicy)
 		return 0;
 
-	get_pgpolicy_name(str, POLICY_NAME_SIZE, pgpolicy);
-
-	return append_strbuf_quoted(buff, str);
+	return append_strbuf_quoted(buff, get_pgpolicy_name(pgpolicy));
 }
 
 declare_def_handler(pgpolicy, set_pgpolicy)
diff --git a/libmultipath/pgpolicies.c b/libmultipath/pgpolicies.c
index e14da8cc..edc3c611 100644
--- a/libmultipath/pgpolicies.c
+++ b/libmultipath/pgpolicies.c
@@ -31,34 +31,23 @@ int get_pgpolicy_id(char * str)
 	return IOPOLICY_UNDEF;
 }
 
-int get_pgpolicy_name(char * buff, int len, int id)
+const char *get_pgpolicy_name(int id)
 {
-	char * s;
-
 	switch (id) {
 	case FAILOVER:
-		s = "failover";
-		break;
+		return "failover";
 	case MULTIBUS:
-		s = "multibus";
-		break;
+		return "multibus";
 	case GROUP_BY_SERIAL:
-		s = "group_by_serial";
-		break;
+		return "group_by_serial";
 	case GROUP_BY_PRIO:
-		s = "group_by_prio";
-		break;
+		return "group_by_prio";
 	case GROUP_BY_NODE_NAME:
-		s = "group_by_node_name";
-		break;
+		return "group_by_node_name";
 	case GROUP_BY_TPG:
-		s = "group_by_tpg";
-		break;
-	default:
-		s = "undefined";
-		break;
+		return "group_by_tpg";
 	}
-	return snprintf(buff, len, "%s", s);
+	return "undefined"; /* IOPOLICY_UNDEF */
 }
 
 
diff --git a/libmultipath/pgpolicies.h b/libmultipath/pgpolicies.h
index d3ab2f35..9e4ddda2 100644
--- a/libmultipath/pgpolicies.h
+++ b/libmultipath/pgpolicies.h
@@ -21,7 +21,7 @@ enum iopolicies {
 };
 
 int get_pgpolicy_id(char *);
-int get_pgpolicy_name (char *, int, int);
+const char *get_pgpolicy_name (int);
 int group_paths(struct multipath *, int);
 /*
  * policies
diff --git a/libmultipath/propsel.c b/libmultipath/propsel.c
index 841fa247..d214281b 100644
--- a/libmultipath/propsel.c
+++ b/libmultipath/propsel.c
@@ -268,7 +268,6 @@ verify_alua_prio(struct multipath *mp)
 int select_pgpolicy(struct config *conf, struct multipath * mp)
 {
 	const char *origin;
-	char buff[POLICY_NAME_SIZE];
 	int log_prio = 3;
 
 	if (conf->pgpolicy_flag > 0) {
@@ -288,9 +287,8 @@ out:
 		log_prio = 1;
 	}
 	mp->pgpolicyfn = pgpolicies[mp->pgpolicy];
-	get_pgpolicy_name(buff, POLICY_NAME_SIZE, mp->pgpolicy);
-	condlog(log_prio, "%s: path_grouping_policy = %s %s", mp->alias, buff,
-		origin);
+	condlog(log_prio, "%s: path_grouping_policy = %s %s", mp->alias,
+		get_pgpolicy_name(mp->pgpolicy), origin);
 	return 0;
 }
 
-- 
2.17.2

--
dm-devel mailing list
dm-devel@redhat.com
https://listman.redhat.com/mailman/listinfo/dm-devel


  parent reply	other threads:[~2023-06-06 20:13 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-06 20:13 [dm-devel] [PATCH V2 00/11] multipath: Add a group_by_tgp pgpolicy Benjamin Marzinski
2023-06-06 20:13 ` [dm-devel] [PATCH V2 01/11] libmultipath: add group_by_tpg path_grouping_policy Benjamin Marzinski
2023-06-07 18:31   ` Martin Wilck
2023-06-07 18:46     ` Benjamin Marzinski
2023-06-06 20:13 ` Benjamin Marzinski [this message]
2023-06-06 20:13 ` [dm-devel] [PATCH V2 03/11] libmultipath: add ALUA tpg path wildcard Benjamin Marzinski
2023-06-06 20:13 ` [dm-devel] [PATCH V2 04/11] multipath-tools tests: add tests for group_by_tpg policy Benjamin Marzinski
2023-06-07 18:35   ` Martin Wilck
2023-06-06 20:13 ` [dm-devel] [PATCH V2 05/11] libmultipath: add "detect_pgpolicy" config option Benjamin Marzinski
2023-06-07 18:36   ` Martin Wilck
2023-06-06 20:13 ` [dm-devel] [PATCH V2 06/11] libmultipath: add "detect_pgpolicy_use_tpg" " Benjamin Marzinski
2023-06-07 18:46   ` Martin Wilck
2023-06-06 20:13 ` [dm-devel] [PATCH V2 07/11] libmultipath: don't count PRIO_UNDEF paths for pathgroup priority Benjamin Marzinski
2023-06-06 20:13 ` [dm-devel] [PATCH V2 08/11] multipath-tools tests: add tests to verify PRIO_UDEF changes Benjamin Marzinski
2023-06-07 18:32   ` Martin Wilck
2023-06-06 20:13 ` [dm-devel] [PATCH V2 09/11] multipathd: only refresh priorities in update_prio() Benjamin Marzinski
2023-06-07 19:00   ` Martin Wilck
2023-06-06 20:13 ` [dm-devel] [PATCH V2 10/11] multipathd: reload map if the path groups are out of order Benjamin Marzinski
2023-06-07 18:59   ` Martin Wilck
2023-06-07 19:43     ` Benjamin Marzinski
2023-06-06 20:13 ` [dm-devel] [PATCH V2 11/11] multipathd: don't assume mpp->paths will exist in need_switch_pathgroup Benjamin Marzinski
2023-06-07 18:42 ` [dm-devel] [PATCH V2 00/11] multipath: Add a group_by_tgp pgpolicy Martin Wilck

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1686082391-29210-3-git-send-email-bmarzins@redhat.com \
    --to=bmarzins@redhat.com \
    --cc=Martin.Wilck@suse.com \
    --cc=christophe.varoqui@opensvc.com \
    --cc=dm-devel@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).