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 v4 02/11] libmultipath: add/remove_feature: use const char* for feature
Date: Thu, 22 Jun 2017 16:59:04 +0200 [thread overview]
Message-ID: <20170622145913.23714-3-mwilck@suse.com> (raw)
In-Reply-To: <20170622145913.23714-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>
Acked-by: Benjamin Marzinski <bmarzins@redhat.com>
Reviewed-by: Hannes Reinecke <hare@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
next prev parent reply other threads:[~2017-06-22 14:59 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-22 14:59 [PATCH v4 00/11] multipath-tools: no_path_retry/queue_if_no_path/hwhandler logic Martin Wilck
2017-06-22 14:59 ` [PATCH v4 01/11] libmultipath: load_config: skip setting unnecessary defaults Martin Wilck
2017-06-22 14:59 ` Martin Wilck [this message]
2017-06-22 14:59 ` [PATCH v4 03/11] libmultipath: clarify option conflicts for "features" Martin Wilck
2017-06-22 14:59 ` [PATCH v4 04/11] libmultipath: merge_hwe: fix queue_if_no_path logic Martin Wilck
2017-06-22 14:59 ` [PATCH v4 05/11] libmultipath: assemble_map: " Martin Wilck
2017-06-22 14:59 ` [PATCH v4 06/11] multipath.conf.5: document no_path_retry vs. queue_if_no_path Martin Wilck
2017-06-22 14:59 ` [PATCH v4 07/11] multipath.conf.5: Remove ??? and other minor fixes Martin Wilck
2017-06-22 14:59 ` [PATCH v4 08/11] libmultipath: add deprecated warning for some features settings Martin Wilck
2017-06-22 14:59 ` [PATCH v4 09/11] libmultipath: retain_attached_hw_handler obsolete with 4.3+ Martin Wilck
2017-06-22 19:09 ` Benjamin Marzinski
2017-06-23 17:25 ` Xose Vazquez Perez
2017-06-26 8:00 ` Martin Wilck
2017-06-22 14:59 ` [PATCH v4 10/11] libmultipath: don't try to set hwhandler if it is retained Martin Wilck
2017-06-22 19:09 ` Benjamin Marzinski
2017-06-22 14:59 ` [PATCH v4 11/11] libmultipath: don't [un]set queue_if_no_path after domap Martin Wilck
2017-08-03 6:36 ` [PATCH v4 00/11] multipath-tools: no_path_retry/queue_if_no_path/hwhandler logic Christophe Varoqui
2017-08-09 13:19 ` 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=20170622145913.23714-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