From patchwork Mon Oct 31 02:55:07 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: ding.yemin@zte.com.cn X-Patchwork-Id: 9404979 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 3FE566022E for ; Mon, 31 Oct 2016 02:59:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3378728F4A for ; Mon, 31 Oct 2016 02:59:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 26FCE28F4E; Mon, 31 Oct 2016 02:59:03 +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 mx4-phx2.redhat.com (mx4-phx2.redhat.com [209.132.183.25]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 8988928F4A for ; Mon, 31 Oct 2016 02:59:02 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx4-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id u9V2uPY6002973; Sun, 30 Oct 2016 22:56:26 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id u9V2uNxW031958 for ; Sun, 30 Oct 2016 22:56:23 -0400 Received: from mx1.redhat.com (ext-mx03.extmail.prod.ext.phx2.redhat.com [10.5.110.27]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u9V2uNFx026145 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Sun, 30 Oct 2016 22:56:23 -0400 Received: from zte.com.cn (mx7.zte.com.cn [202.103.147.169]) by mx1.redhat.com (Postfix) with ESMTP id 812B481F03; Mon, 31 Oct 2016 02:56:17 +0000 (UTC) Received: from mse01.zte.com.cn (unknown [10.30.3.20]) by Websense Email Security Gateway with ESMTP id EDDB9435DEEB7; Mon, 31 Oct 2016 10:56:11 +0800 (CST) Received: from notes_smtp.zte.com.cn ([10.30.1.239]) by mse01.zte.com.cn with ESMTP id u9V2u0ik039039; Mon, 31 Oct 2016 10:56:00 +0800 (GMT-8) (envelope-from ding.yemin@zte.com.cn) Received: from localhost.localdomain ([10.118.202.203]) by szsmtp06.zte.com.cn (Lotus Domino Release 8.5.3FP6) with ESMTP id 2016103110560182-2677903 ; Mon, 31 Oct 2016 10:56:01 +0800 From: ding.yemin@zte.com.cn To: Christophe Varoqui Date: Mon, 31 Oct 2016 10:55:07 +0800 Message-Id: <1477882507-6408-1-git-send-email-ding.yemin@zte.com.cn> X-MIMETrack: Itemize by SMTP Server on SZSMTP06/server/zte_ltd(Release 8.5.3FP6|November 21, 2013) at 2016-10-31 10:56:02, Serialize by Router on notes_smtp/zte_ltd(Release 8.5.3FP6|November 21, 2013) at 2016-10-31 10:55:49, Serialize complete at 2016-10-31 10:55:49 X-MAIL: mse01.zte.com.cn u9V2u0ik039039 X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 191 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Mon, 31 Oct 2016 02:56:20 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Mon, 31 Oct 2016 02:56:20 +0000 (UTC) for IP:'202.103.147.169' DOMAIN:'mx7.zte.com.cn' HELO:'zte.com.cn' FROM:'ding.yemin@zte.com.cn' RCPT:'' X-RedHat-Spam-Score: -5.379 (BAYES_40, DCC_REPUT_00_12, RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, RP_MATCHES_RCVD, SPF_HELO_PASS, SPF_PASS) 202.103.147.169 mx7.zte.com.cn 202.103.147.169 mx7.zte.com.cn X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-Scanned-By: MIMEDefang 2.78 on 10.5.110.27 X-loop: dm-devel@redhat.com Cc: tang.junhui@zte.com.cn, zhang.kai16@zte.com.cn, "ding.yemin" , dm-devel@redhat.com, bart.vanassche@sandisk.com Subject: [dm-devel] [PATCH] Remove duplicated code in mpath_alloc_prin_response() 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-Virus-Scanned: ClamAV using ClamSMTP From: "ding.yemin" Remove duplicated code in mpath_alloc_prin_response(). Signed-off-by: ding.yemin --- libmpathpersist/mpath_persist.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/libmpathpersist/mpath_persist.c b/libmpathpersist/mpath_persist.c index 7501651..633e462 100644 --- a/libmpathpersist/mpath_persist.c +++ b/libmpathpersist/mpath_persist.c @@ -833,26 +833,22 @@ void * mpath_alloc_prin_response(int prin_sa) { case MPATH_PRIN_RKEY_SA: size = sizeof(struct prin_readdescr); - ptr = malloc(size); - memset(ptr, 0, size); break; case MPATH_PRIN_RRES_SA: size = sizeof(struct prin_resvdescr); - ptr = malloc(size); - memset(ptr, 0, size); break; case MPATH_PRIN_RCAP_SA: size=sizeof(struct prin_capdescr); - ptr = malloc(size); - memset(ptr, 0, size); break; case MPATH_PRIN_RFSTAT_SA: size = sizeof(struct print_fulldescr_list) + sizeof(struct prin_fulldescr *)*MPATH_MX_TIDS; - ptr = malloc(size); - memset(ptr, 0, size); break; } + if (size > 0) + { + ptr = calloc(size, 1); + } return ptr; }