Skip to contentSkip to conversation

rdma/cma: minor code refactoring when saving a string content

PATCH In review Dotan Barak 2 participants 2 messages Oct 30, 2011 – Oct 31, 2011 1 message not in the archive InfiniBand

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 rdma/cma: minor code refactoring when saving a string content

In this case, using strdup will provide a cleaner code (and maybe a little bit faster too).

---

 src/addrinfo.c |    4 +---
 1 files changed, 1 insertions(+), 3 deletions(-)
src/addrinfo.c +1 -3
index 695430b..34c7fb4 100755
@@ -137,9 +137,7 @@ static int ucma_convert_to_rai(struct rdma_addrinfo *rai,
 	if (!addr)
 		return ERR(ENOMEM);
 
-	canonname = ai->ai_canonname ? malloc(strlen(ai->ai_canonname) + 1) : NULL;
-	if (canonname)
-		strcpy(canonname, ai->ai_canonname);
+	canonname = ai->ai_canonname ? strdup(ai->ai_canonname) : NULL;
 
 	memcpy(addr, ai->ai_addr, ai->ai_addrlen);
 	if (ai->ai_flags & RAI_PASSIVE) {

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 201110301348.05062.dotanb-g2bIKuvJtcQanlnWow0HJg@public.gmane.org