From: "ding.yemin" <[email protected]>

Remove duplicated code in mpath_alloc_prin_response().

Signed-off-by: ding.yemin <[email protected]>
---
 libmpathpersist/mpath_persist.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/libmpathpersist/mpath_persist.c b/libmpathpersist/mpath_persist.c
index 7501651..5962756 100644
--- a/libmpathpersist/mpath_persist.c
+++ b/libmpathpersist/mpath_persist.c
@@ -833,26 +833,26 @@ 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 = malloc(size);
+               if (ptr)
+               {
+                       memset(ptr, 0, size);
+               }
+       }
        return ptr;
 }
 
-- 
2.8.1.windows.1

--
dm-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/dm-devel

Reply via email to