[PATCH] Remove duplicated code in mpath_alloc_prin_response()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: "ding.yemin" <ding.yemin@xxxxxxxxxx>

Remove duplicated code in mpath_alloc_prin_response().

Signed-off-by: ding.yemin <ding.yemin@xxxxxxxxxx>
---
 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
dm-devel@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/dm-devel



[Index of Archives]     [DM Crypt]     [Fedora Desktop]     [ATA RAID]     [Fedora Marketing]     [Fedora Packaging]     [Fedora SELinux]     [Yosemite Discussion]     [KDE Users]     [Fedora Docs]

  Powered by Linux