[dm-devel] [PATCH] Remove duplicated code in mpath_alloc_prin_response()
ding.yemin at zte.com.cn
ding.yemin at zte.com.cn
Mon Oct 31 02:55:07 UTC 2016
From: "ding.yemin" <ding.yemin at zte.com.cn>
Remove duplicated code in mpath_alloc_prin_response().
Signed-off-by: ding.yemin <ding.yemin at 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
More information about the dm-devel
mailing list