From: Hannes Reinecke <hare@suse.de>
To: Martin Wilck <mwilck@suse.com>,
Christophe Varoqui <christophe.varoqui@opensvc.com>,
Benjamin Marzinski <bmarzins@redhat.com>
Cc: dm-devel@redhat.com
Subject: Re: [PATCH 2/4] libmultipath: add_feature: skip pointless NULL check
Date: Tue, 29 Aug 2017 08:37:51 +0200 [thread overview]
Message-ID: <59b6a581-78e2-1020-a85e-bb7a151b8986@suse.de> (raw)
In-Reply-To: <20170828220536.13208-2-mwilck@suse.com>
On 08/29/2017 12:05 AM, Martin Wilck wrote:
> The case f == NULL is already handled by the code from
> b1ecdd46b6ec "segment faulty occured in add_feature()" above.
>
> Signed-off-by: Martin Wilck <mwilck@suse.com>
> ---
> libmultipath/structs.c | 27 ++++++++++++---------------
> 1 file changed, 12 insertions(+), 15 deletions(-)
>
> diff --git a/libmultipath/structs.c b/libmultipath/structs.c
> index 28704676..11e33676 100644
> --- a/libmultipath/structs.c
> +++ b/libmultipath/structs.c
> @@ -515,7 +515,7 @@ void setup_feature(struct multipath *mpp, char *feature)
>
> int add_feature(char **f, const char *n)
> {
> - int c = 0, d, l = 0;
> + int c = 0, d, l;
> char *e, *p, *t;
> const char *q;
>
> @@ -538,19 +538,18 @@ int add_feature(char **f, const char *n)
> }
>
> /* Check if feature is already present */
> - if (*f) {
> - if (strstr(*f, n))
> - return 0;
> + if (strstr(*f, n))
> + return 0;
>
> - /* Get feature count */
> - c = strtoul(*f, &e, 10);
> - if (*f == e)
> - /* parse error */
> - return 1;
> + /* Get feature count */
> + c = strtoul(*f, &e, 10);
> + if (*f == e)
> + /* parse error */
> + return 1;
> +
> + /* Check if we need to increase feature count space */
> + l = strlen(*f) + strlen(n) + 1;
>
> - /* Check if we need to increase feature count space */
> - l = strlen(*f) + strlen(n) + 1;
> - }
> /* Count new features */
> if ((c % 10) == 9)
> l++;
> @@ -582,9 +581,7 @@ int add_feature(char **f, const char *n)
> snprintf(p, l + 2, "%0d ", c);
>
> /* Copy the feature string */
> - p = NULL;
> - if (*f)
> - p = strchr(*f, ' ');
> + p = strchr(*f, ' ');
>
> if (p) {
> while (*p == ' ')
>
At one point we should have a test case for adding/removing features...
Reviewed-by: Hannes Reinecke <hare@suse.com>
Cheers,
Hannes
--
Dr. Hannes Reinecke Teamlead Storage & Networking
hare@suse.de +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
HRB 21284 (AG Nürnberg)
--
dm-devel mailing list
dm-devel@redhat.com
https://www.redhat.com/mailman/listinfo/dm-devel
next prev parent reply other threads:[~2017-08-29 6:37 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-28 22:05 [PATCH 1/4] multipathd: don't flood system with sd_notify calls Martin Wilck
2017-08-28 22:05 ` [PATCH 2/4] libmultipath: add_feature: skip pointless NULL check Martin Wilck
2017-08-29 6:37 ` Hannes Reinecke [this message]
2017-08-29 7:21 ` Martin Wilck
2017-09-07 21:33 ` Benjamin Marzinski
2017-08-28 22:05 ` [PATCH 3/4] libmultipath: add_feature: allow only 1 feature Martin Wilck
2017-08-29 6:39 ` Hannes Reinecke
2017-09-07 21:42 ` Benjamin Marzinski
2017-09-07 22:37 ` Benjamin Marzinski
2017-08-28 22:05 ` [PATCH 4/4] multipath: delegate dangerous commands to multipathd Martin Wilck
2017-08-29 6:40 ` Hannes Reinecke
2017-09-07 21:57 ` Benjamin Marzinski
2017-09-08 8:16 ` Martin Wilck
2017-08-29 6:36 ` [PATCH 1/4] multipathd: don't flood system with sd_notify calls Hannes Reinecke
2017-09-07 21:31 ` Benjamin Marzinski
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=59b6a581-78e2-1020-a85e-bb7a151b8986@suse.de \
--to=hare@suse.de \
--cc=bmarzins@redhat.com \
--cc=christophe.varoqui@opensvc.com \
--cc=dm-devel@redhat.com \
--cc=mwilck@suse.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.