From patchwork Tue Sep 5 13:45:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guan Junxiong X-Patchwork-Id: 9939097 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 E77216038C for ; Tue, 5 Sep 2017 13:51:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D904C28992 for ; Tue, 5 Sep 2017 13:51:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CD95128996; Tue, 5 Sep 2017 13:51:48 +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 489F028992 for ; Tue, 5 Sep 2017 13:51:48 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D312264114; Tue, 5 Sep 2017 13:51:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com D312264114 Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=huawei.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=dm-devel-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com D312264114 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 ACB79E996B; Tue, 5 Sep 2017 13:51:46 +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 7C4D91806106; Tue, 5 Sep 2017 13:51:46 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v85DjWi8003517 for ; Tue, 5 Sep 2017 09:45:32 -0400 Received: by smtp.corp.redhat.com (Postfix) id E05396BF6C; Tue, 5 Sep 2017 13:45:32 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from mx1.redhat.com (ext-mx07.extmail.prod.ext.phx2.redhat.com [10.5.110.31]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A61907FB8D; Tue, 5 Sep 2017 13:45:30 +0000 (UTC) Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) (using TLSv1 with cipher RC4-SHA (112/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 56333C014161; Tue, 5 Sep 2017 13:45:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 56333C014161 Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=huawei.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=guanjunxiong@huawei.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 56333C014161 Received: from 172.30.72.60 (EHLO DGGEMS410-HUB.china.huawei.com) ([172.30.72.60]) by dggrg04-dlp.huawei.com (MOS 4.4.6-GA FastPath queued) with ESMTP id DGO41633; Tue, 05 Sep 2017 21:45:25 +0800 (CST) Received: from huawei.com (10.169.94.217) by DGGEMS410-HUB.china.huawei.com (10.3.19.210) with Microsoft SMTP Server id 14.3.301.0; Tue, 5 Sep 2017 21:45:15 +0800 From: Guan Junxiong To: , , , , , Date: Tue, 5 Sep 2017 21:45:04 +0800 Message-ID: <1504619105-14788-3-git-send-email-guanjunxiong@huawei.com> In-Reply-To: <1504619105-14788-1-git-send-email-guanjunxiong@huawei.com> References: <1504619105-14788-1-git-send-email-guanjunxiong@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.169.94.217] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020202.59AEAA76.00B0, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0, so=2014-11-16 11:51:01, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 47dced5ddd8d32010a0a53ab17a76425 X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Tue, 05 Sep 2017 13:45:29 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Tue, 05 Sep 2017 13:45:29 +0000 (UTC) for IP:'45.249.212.190' DOMAIN:'szxga04-in.huawei.com' HELO:'szxga04-in.huawei.com' FROM:'guanjunxiong@huawei.com' RCPT:'' X-RedHat-Spam-Score: -0.002 (RP_MATCHES_RCVD, SPF_PASS) 45.249.212.190 szxga04-in.huawei.com 45.249.212.190 szxga04-in.huawei.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.31 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: dm-devel@redhat.com Cc: guanjunxiong@huawei.com, philip.yang@huawei.com, niuhaoxin@huawei.com, shenhong09@huawei.com, chengjike.cheng@huawei.com Subject: [dm-devel] [PATCH 2/3] multipath-tools: move get_next_string to util 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: , Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Tue, 05 Sep 2017 13:51:47 +0000 (UTC) X-Virus-Scanned: ClamAV using ClamSMTP The helper get_next_string is useful and generic. So move from exclusive weightedpath module to util module. It will be used in the next second patch. Signed-off-by: Junxiong Guan --- libmultipath/prioritizers/weightedpath.c | 10 +--------- libmultipath/util.c | 9 +++++++++ libmultipath/util.h | 1 + 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/libmultipath/prioritizers/weightedpath.c b/libmultipath/prioritizers/weightedpath.c index 34a43a81..e0f3efbb 100644 --- a/libmultipath/prioritizers/weightedpath.c +++ b/libmultipath/prioritizers/weightedpath.c @@ -34,15 +34,7 @@ #include #include "structs_vec.h" #include "print.h" - -char *get_next_string(char **temp, char *split_char) -{ - char *token = NULL; - token = strsep(temp, split_char); - while (token != NULL && !strcmp(token, "")) - token = strsep(temp, split_char); - return token; -} +#include "util.h" #define CHECK_LEN \ do { \ diff --git a/libmultipath/util.c b/libmultipath/util.c index dff2ed3c..528ba73b 100644 --- a/libmultipath/util.c +++ b/libmultipath/util.c @@ -64,6 +64,15 @@ filepresent (char * run) { return 0; } +char *get_next_string(char **temp, char *split_char) +{ + char *token = NULL; + token = strsep(temp, split_char); + while (token != NULL && !strcmp(token, "")) + token = strsep(temp, split_char); + return token; +} + int get_word (char * sentence, char ** word) { diff --git a/libmultipath/util.h b/libmultipath/util.h index 45291be8..584ad948 100644 --- a/libmultipath/util.h +++ b/libmultipath/util.h @@ -6,6 +6,7 @@ size_t strchop(char *); int basenamecpy (const char * src, char * dst, int); int filepresent (char * run); +char *get_next_string(char **temp, char *split_char); int get_word (char * sentence, char ** word); size_t strlcpy(char *dst, const char *src, size_t size); size_t strlcat(char *dst, const char *src, size_t size);