From patchwork Tue Jun 20 11:46:08 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Wilck X-Patchwork-Id: 9799281 X-Patchwork-Delegate: snitzer@redhat.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 5B303603F1 for ; Tue, 20 Jun 2017 11:47:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4CD8928451 for ; Tue, 20 Jun 2017 11:47:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 416402847B; Tue, 20 Jun 2017 11:47:05 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id CE7BB2847F for ; Tue, 20 Jun 2017 11:47:01 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6D9E1C03BD6B; Tue, 20 Jun 2017 11:47:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 6D9E1C03BD6B Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=suse.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=dm-devel-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 6D9E1C03BD6B Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 042B7867AB; Tue, 20 Jun 2017 11:47:00 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id D55A441F78; Tue, 20 Jun 2017 11:46:56 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v5KBkt88026865 for ; Tue, 20 Jun 2017 07:46:55 -0400 Received: by smtp.corp.redhat.com (Postfix) id 449B0867C3; Tue, 20 Jun 2017 11:46:55 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from mx1.redhat.com (ext-mx01.extmail.prod.ext.phx2.redhat.com [10.5.110.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 874E17F5F2; Tue, 20 Jun 2017 11:46:53 +0000 (UTC) Received: from prv3-mh.provo.novell.com (prv3-mh.provo.novell.com [137.65.250.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3404A80E72; Tue, 20 Jun 2017 11:46:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 3404A80E72 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=suse.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=mwilck@suse.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 3404A80E72 Received: from apollon.suse.de.de (prv-ext-foundry1int.gns.novell.com [137.65.251.240]) by prv3-mh.provo.novell.com with ESMTP (TLS encrypted); Tue, 20 Jun 2017 05:46:38 -0600 From: Martin Wilck To: Christophe Varoqui , Hannes Reinecke Date: Tue, 20 Jun 2017 13:46:08 +0200 Message-Id: <20170620114614.26261-3-mwilck@suse.com> In-Reply-To: <20170620114614.26261-1-mwilck@suse.com> References: <20170620114614.26261-1-mwilck@suse.com> X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 203 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Tue, 20 Jun 2017 11:46:52 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Tue, 20 Jun 2017 11:46:52 +0000 (UTC) for IP:'137.65.250.26' DOMAIN:'prv3-mh.provo.novell.com' HELO:'prv3-mh.provo.novell.com' FROM:'mwilck@suse.com' RCPT:'' X-RedHat-Spam-Score: -1.501 (BAYES_50, RCVD_IN_DNSWL_MED, SPF_PASS) 137.65.250.26 prv3-mh.provo.novell.com 137.65.250.26 prv3-mh.provo.novell.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.25 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: dm-devel@redhat.com Cc: dm-devel@redhat.com, Xose Vazquez Perez Subject: [dm-devel] [PATCH v2 2/8] libmultipath: add/remove_feature: use const char* for feature X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Tue, 20 Jun 2017 11:47:01 +0000 (UTC) X-Virus-Scanned: ClamAV using ClamSMTP 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 Reviewed-by: Hannes Reinecke --- 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];