In this case, using strdup will provide a cleaner code (and maybe a little bit faster too).
Signed-off-by: Dotan Barak <[email protected]> --- src/addrinfo.c | 4 +--- 1 files changed, 1 insertions(+), 3 deletions(-) diff --git a/src/addrinfo.c b/src/addrinfo.c index 695430b..34c7fb4 100755 --- a/src/addrinfo.c +++ b/src/addrinfo.c @@ -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
