Linux Device Mapper development
 help / color / mirror / Atom feed
From: Martin Wilck <mwilck@suse.com>
To: Christophe Varoqui <christophe.varoqui@opensvc.com>,
	Hannes Reinecke <hare@suse.de>
Cc: dm-devel@redhat.com, Xose Vazquez Perez <xose.vazquez@gmail.com>
Subject: [PATCH v2 2/8] libmultipath: add/remove_feature: use const char* for feature
Date: Tue, 20 Jun 2017 13:46:08 +0200	[thread overview]
Message-ID: <20170620114614.26261-3-mwilck@suse.com> (raw)
In-Reply-To: <20170620114614.26261-1-mwilck@suse.com>

Change the argument type for the feature to add or remove to
const char*, making it possible to pass const strings without
warnings.

Signed-off-by: Martin Wilck <mwilck@suse.com>
---
 libmultipath/structs.c | 30 ++++++++++++++++--------------
 libmultipath/structs.h |  4 ++--
 2 files changed, 18 insertions(+), 16 deletions(-)

diff --git a/libmultipath/structs.c b/libmultipath/structs.c
index e225f8b4..28704676 100644
--- a/libmultipath/structs.c
+++ b/libmultipath/structs.c
@@ -513,10 +513,11 @@ void setup_feature(struct multipath *mpp, char *feature)
 	}
 }
 
-int add_feature(char **f, char *n)
+int add_feature(char **f, const char *n)
 {
 	int c = 0, d, l = 0;
 	char *e, *p, *t;
+	const char *q;
 
 	if (!f)
 		return 1;
@@ -554,14 +555,14 @@ int add_feature(char **f, char *n)
 	if ((c % 10) == 9)
 		l++;
 	c++;
-	p = n;
-	while (*p != '\0') {
-		if (*p == ' ' && p[1] != '\0' && p[1] != ' ') {
+	q = n;
+	while (*q != '\0') {
+		if (*q == ' ' && q[1] != '\0' && q[1] != ' ') {
 			if ((c % 10) == 9)
 				l++;
 			c++;
 		}
-		p++;
+		q++;
 	}
 
 	t = MALLOC(l + 1);
@@ -601,10 +602,11 @@ int add_feature(char **f, char *n)
 	return 0;
 }
 
-int remove_feature(char **f, char *o)
+int remove_feature(char **f, const char *o)
 {
 	int c = 0, d, l;
 	char *e, *p, *n;
+	const char *q;
 
 	if (!f || !*f)
 		return 1;
@@ -630,18 +632,18 @@ int remove_feature(char **f, char *o)
 	/* Just spaces, return */
 	if (*o == '\0')
 		return 0;
-	e = o + strlen(o);
-	while (*e == ' ')
-		e--;
-	d = (int)(e - o);
+	q = o + strlen(o);
+	while (*q == ' ')
+		q--;
+	d = (int)(q - o);
 
 	/* Update feature count */
 	c--;
-	p = o;
-	while (p[0] != '\0') {
-		if (p[0] == ' ' && p[1] != ' ' && p[1] != '\0')
+	q = o;
+	while (q[0] != '\0') {
+		if (q[0] == ' ' && q[1] != ' ' && q[1] != '\0')
 			c--;
-		p++;
+		q++;
 	}
 
 	/* Quick exit if all features have been removed */
diff --git a/libmultipath/structs.h b/libmultipath/structs.h
index 01e031ad..8ea984d9 100644
--- a/libmultipath/structs.h
+++ b/libmultipath/structs.h
@@ -369,8 +369,8 @@ int pathcountgr (struct pathgroup *, int);
 int pathcount (struct multipath *, int);
 int pathcmp (struct pathgroup *, struct pathgroup *);
 void setup_feature(struct multipath *, char *);
-int add_feature (char **, char *);
-int remove_feature (char **, char *);
+int add_feature (char **, const char *);
+int remove_feature (char **, const char *);
 
 extern char sysfs_path[PATH_SIZE];
 
-- 
2.13.1

  parent reply	other threads:[~2017-06-20 11:46 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-20 11:46 [PATCH v2 0/8] multipath-tools: no_path_retry/queue_if_no_path logic Martin Wilck
2017-06-20 11:46 ` [PATCH v2 1/8] libmultipath: load_config: skip setting unnecessary defaults Martin Wilck
2017-06-20 14:36   ` Hannes Reinecke
2017-06-20 16:25     ` Benjamin Marzinski
2017-06-20 18:28     ` [PATCH] Clarify commit message in select_max_sectors_kb() Martin Wilck
2017-06-20 11:46 ` Martin Wilck [this message]
2017-06-20 15:01   ` [PATCH v2 2/8] libmultipath: add/remove_feature: use const char* for feature Hannes Reinecke
2017-06-20 11:46 ` [PATCH v2 3/8] libmultipath: clarify option conflicts for "features" Martin Wilck
2017-06-20 11:46 ` [PATCH v2 4/8] libmultipath: merge_hwe: fix queue_if_no_path logic Martin Wilck
2017-06-20 11:46 ` [PATCH v2 5/8] libmultipath: assemble_map: " Martin Wilck
2017-06-20 11:46 ` [PATCH v2 6/8] multipath.conf.5: document no_path_retry vs. queue_if_no_path Martin Wilck
2017-06-20 11:46 ` [PATCH v2 7/8] multipath.conf.5: Remove ??? and other minor fixes Martin Wilck
2017-06-20 11:46 ` [PATCH v2 8/8] libmultipath: add deprecated warning for some features settings Martin Wilck
2017-06-20 18:44 ` [PATCH v2 0/8] multipath-tools: no_path_retry/queue_if_no_path logic Benjamin Marzinski
2017-06-20 19:04   ` Martin Wilck
2017-06-20 21:54   ` 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=20170620114614.26261-3-mwilck@suse.com \
    --to=mwilck@suse.com \
    --cc=christophe.varoqui@opensvc.com \
    --cc=dm-devel@redhat.com \
    --cc=hare@suse.de \
    --cc=xose.vazquez@gmail.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