All of lore.kernel.org
 help / color / mirror / Atom feed
From: ding.yemin@zte.com.cn
To: Christophe Varoqui <christophe.varoqui@opensvc.com>
Cc: tang.junhui@zte.com.cn, zhang.kai16@zte.com.cn,
	"ding.yemin" <ding.yemin@zte.com.cn>,
	dm-devel@redhat.com, bart.vanassche@sandisk.com
Subject: [PATCH] Remove duplicated code in mpath_alloc_prin_response()
Date: Mon, 31 Oct 2016 10:55:07 +0800	[thread overview]
Message-ID: <1477882507-6408-1-git-send-email-ding.yemin@zte.com.cn> (raw)

From: "ding.yemin" <ding.yemin@zte.com.cn>

Remove duplicated code in mpath_alloc_prin_response().

Signed-off-by: ding.yemin <ding.yemin@zte.com.cn>
---
 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;
 }
 
-- 
2.8.1.windows.1

             reply	other threads:[~2016-10-31  2:55 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-31  2:55 ding.yemin [this message]
  -- strict thread matches above, loose matches on Subject: below --
2016-10-25  8:19 [PATCH] Remove duplicated code in mpath_alloc_prin_response() ding.yemin
2016-10-28 15:16 ` Bart Van Assche
2016-10-31  2:03   ` ding.yemin

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=1477882507-6408-1-git-send-email-ding.yemin@zte.com.cn \
    --to=ding.yemin@zte.com.cn \
    --cc=bart.vanassche@sandisk.com \
    --cc=christophe.varoqui@opensvc.com \
    --cc=dm-devel@redhat.com \
    --cc=tang.junhui@zte.com.cn \
    --cc=zhang.kai16@zte.com.cn \
    /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.