From patchwork Mon Mar 5 23:14:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Wilck X-Patchwork-Id: 10260289 X-Patchwork-Delegate: christophe.varoqui@free.fr 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 14DA060134 for ; Mon, 5 Mar 2018 23:56:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F2CB3288EA for ; Mon, 5 Mar 2018 23:56:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E72EF28CF6; Mon, 5 Mar 2018 23:56:24 +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 3F63E288EA for ; Mon, 5 Mar 2018 23:56:23 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B4474356EB; Mon, 5 Mar 2018 23:56:22 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2D38F608FA; Mon, 5 Mar 2018 23:56:22 +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 6381B18033EA; Mon, 5 Mar 2018 23:56:21 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w25NuJBq024549 for ; Mon, 5 Mar 2018 18:56:19 -0500 Received: by smtp.corp.redhat.com (Postfix) id A08255EE08; Mon, 5 Mar 2018 23:56:19 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from mx1.redhat.com (ext-mx06.extmail.prod.ext.phx2.redhat.com [10.5.110.30]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8BB545D75C; Mon, 5 Mar 2018 23:56:17 +0000 (UTC) Received: from smtp.nue.novell.com (smtp.nue.novell.com [195.135.221.5]) (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 77621356CC; Mon, 5 Mar 2018 23:56:15 +0000 (UTC) Received: from emea4-mta.ukb.novell.com ([10.120.13.87]) by smtp.nue.novell.com with ESMTP (TLS encrypted); Tue, 06 Mar 2018 00:36:12 +0100 Received: from apollon.suse.de.de (nwb-a10-snat.microfocus.com [10.120.13.202]) by emea4-mta.ukb.novell.com with ESMTP (TLS encrypted); Mon, 05 Mar 2018 23:15:38 +0000 From: Martin Wilck To: Christophe Varoqui Date: Tue, 6 Mar 2018 00:14:51 +0100 Message-Id: <20180305231507.10386-8-mwilck@suse.com> In-Reply-To: <20180305231507.10386-1-mwilck@suse.com> References: <20180305231507.10386-1-mwilck@suse.com> X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 207 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Mon, 05 Mar 2018 23:56:16 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Mon, 05 Mar 2018 23:56:16 +0000 (UTC) for IP:'195.135.221.5' DOMAIN:'smtp.nue.novell.com' HELO:'smtp.nue.novell.com' FROM:'mwilck@suse.com' RCPT:'' X-RedHat-Spam-Score: -2.301 (RCVD_IN_DNSWL_MED, SPF_PASS) 195.135.221.5 smtp.nue.novell.com 195.135.221.5 smtp.nue.novell.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.30 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: dm-devel@redhat.com Cc: dm-devel@redhat.com, Martin Wilck Subject: [dm-devel] [PATCH v2 07/23] libmultipath: use "const" in devmapper code 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.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Mon, 05 Mar 2018 23:56:23 +0000 (UTC) X-Virus-Scanned: ClamAV using ClamSMTP Improve use of "const" qualifiers in libmultipath's devmapper code. Signed-off-by: Martin Wilck Reviewed-by: Benjamin Marzinski Reviewed-by: Hannes Reinecke --- libmultipath/devmapper.c | 32 ++++++++++++++++---------------- libmultipath/devmapper.h | 16 ++++++++-------- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/libmultipath/devmapper.c b/libmultipath/devmapper.c index f112e1cb0e66..f61838cbe369 100644 --- a/libmultipath/devmapper.c +++ b/libmultipath/devmapper.c @@ -583,7 +583,7 @@ is_mpath_part(const char *part_name, const char *map_name) return 0; } -int dm_get_status(char *name, char *outstatus) +int dm_get_status(const char *name, char *outstatus) { int r = 1; struct dm_task *dmt; @@ -807,7 +807,7 @@ int _dm_flush_map (const char * mapname, int need_sync, int deferred_remove, if (need_suspend && !dm_get_map(mapname, &mapsize, params) && strstr(params, "queue_if_no_path")) { - if (!dm_queue_if_no_path((char *)mapname, 0)) + if (!dm_queue_if_no_path(mapname, 0)) queue_if_no_path = 1; else /* Leave queue_if_no_path alone if unset failed */ @@ -850,7 +850,7 @@ int _dm_flush_map (const char * mapname, int need_sync, int deferred_remove, } while (retries-- > 0); if (queue_if_no_path == 1) - dm_queue_if_no_path((char *)mapname, 1); + dm_queue_if_no_path(mapname, 1); return 1; } @@ -938,7 +938,7 @@ out: } int -dm_fail_path(char * mapname, char * path) +dm_fail_path(const char * mapname, char * path) { char message[32]; @@ -949,7 +949,7 @@ dm_fail_path(char * mapname, char * path) } int -dm_reinstate_path(char * mapname, char * path) +dm_reinstate_path(const char * mapname, char * path) { char message[32]; @@ -960,7 +960,7 @@ dm_reinstate_path(char * mapname, char * path) } int -dm_queue_if_no_path(char *mapname, int enable) +dm_queue_if_no_path(const char *mapname, int enable) { char *message; @@ -973,7 +973,7 @@ dm_queue_if_no_path(char *mapname, int enable) } static int -dm_groupmsg (char * msg, char * mapname, int index) +dm_groupmsg (const char * msg, const char * mapname, int index) { char message[32]; @@ -984,19 +984,19 @@ dm_groupmsg (char * msg, char * mapname, int index) } int -dm_switchgroup(char * mapname, int index) +dm_switchgroup(const char * mapname, int index) { return dm_groupmsg("switch", mapname, index); } int -dm_enablegroup(char * mapname, int index) +dm_enablegroup(const char * mapname, int index) { return dm_groupmsg("enable", mapname, index); } int -dm_disablegroup(char * mapname, int index) +dm_disablegroup(const char * mapname, int index) { return dm_groupmsg("disable", mapname, index); } @@ -1080,7 +1080,7 @@ out: } int -dm_geteventnr (char *name) +dm_geteventnr (const char *name) { struct dm_info info; @@ -1139,7 +1139,7 @@ dm_mapname(int major, int minor) map = dm_task_get_name(dmt); if (map && strlen(map)) - response = STRDUP((char *)dm_task_get_name(dmt)); + response = STRDUP((const char *)dm_task_get_name(dmt)); dm_task_destroy(dmt); return response; @@ -1264,7 +1264,7 @@ cancel_remove_partmap (const char *name, void *unused) } static int -dm_get_deferred_remove (char * mapname) +dm_get_deferred_remove (const char * mapname) { struct dm_info info; @@ -1412,10 +1412,10 @@ out: return r; } -void dm_reassign_deps(char *table, char *dep, char *newdep) +void dm_reassign_deps(char *table, const char *dep, const char *newdep) { - char *p, *n; - char *newtable; + char *n; + const char *p, *newtable; newtable = strdup(table); if (!newtable) diff --git a/libmultipath/devmapper.h b/libmultipath/devmapper.h index 558e6914074f..8c8ea6c29b27 100644 --- a/libmultipath/devmapper.h +++ b/libmultipath/devmapper.h @@ -38,7 +38,7 @@ int dm_addmap_create (struct multipath *mpp, char *params); int dm_addmap_reload (struct multipath *mpp, char *params, int flush); int dm_map_present (const char *); int dm_get_map(const char *, unsigned long long *, char *); -int dm_get_status(char *, char *); +int dm_get_status(const char *, char *); int dm_type(const char *, char *); int dm_is_mpath(const char *); int _dm_flush_map (const char *, int, int, int, int); @@ -49,14 +49,14 @@ int dm_flush_map_nopaths(const char * mapname, int deferred_remove); _dm_flush_map(mapname, 1, 0, 1, retries) int dm_cancel_deferred_remove(struct multipath *mpp); int dm_flush_maps (int retries); -int dm_fail_path(char * mapname, char * path); -int dm_reinstate_path(char * mapname, char * path); -int dm_queue_if_no_path(char *mapname, int enable); -int dm_switchgroup(char * mapname, int index); -int dm_enablegroup(char * mapname, int index); -int dm_disablegroup(char * mapname, int index); +int dm_fail_path(const char * mapname, char * path); +int dm_reinstate_path(const char * mapname, char * path); +int dm_queue_if_no_path(const char *mapname, int enable); +int dm_switchgroup(const char * mapname, int index); +int dm_enablegroup(const char * mapname, int index); +int dm_disablegroup(const char * mapname, int index); int dm_get_maps (vector mp); -int dm_geteventnr (char *name); +int dm_geteventnr (const char *name); int dm_is_suspended(const char *name); int dm_get_major_minor (const char *name, int *major, int *minor); char * dm_mapname(int major, int minor);