Remove duplicated code in mpath_alloc_prin_response()
authording.yemin <ding.yemin@zte.com.cn>
Mon, 31 Oct 2016 02:55:07 +0000 (10:55 +0800)
committerChristophe Varoqui <christophe.varoqui@opensvc.com>
Thu, 3 Nov 2016 13:28:43 +0000 (14:28 +0100)
Remove duplicated code in mpath_alloc_prin_response().

Signed-off-by: ding.yemin <ding.yemin@zte.com.cn>
libmpathpersist/mpath_persist.c

index 7501651..633e462 100644 (file)
@@ -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;
 }