X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Futils%2Fnidlist.c;h=3b04d32acf449171e4eb74f9818cb520581a3cd0;hb=393350b37cae30efc03ffc076c77e390999c2a2d;hp=fb0cbecd1e76d07321014667ac11ac86ba9e4b84;hpb=2177e48c99e9f63c8d64cdc032de78284ac85381;p=fs%2Flustre-release.git diff --git a/lustre/utils/nidlist.c b/lustre/utils/nidlist.c index fb0cbec..3b04d32 100644 --- a/lustre/utils/nidlist.c +++ b/lustre/utils/nidlist.c @@ -1,6 +1,4 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * +/* * GPL HEADER START * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -26,7 +24,7 @@ * GPL HEADER END */ /* - * Copyright 2008 Sun Microsystems, Inc. All rights reserved + * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. * Use is subject to license terms. */ /* @@ -210,19 +208,25 @@ static char *nl_nid_lookup_ipaddr(char *nid) NI_NAMEREQD | NI_NOFQDN) == 0) { if ((p = strchr(name, '.'))) *p = '\0'; - len = strlen(name) + strlen(lnet) + 2; - if (!(res = malloc(len))) - nl_oom(); - snprintf(res, len, "%s@%s", name, lnet); - break; - } - } - freeaddrinfo(ai); - } - } - free(addr); + len = strlen(name) + 2; + if (lnet != NULL) + len += strlen(lnet); + if (!(res = malloc(len))) + nl_oom(); + if (lnet != NULL) + snprintf(res, len, "%s@%s", + name, lnet); + else + snprintf(res, len, "%s", name); + break; + } + } + freeaddrinfo(ai); + } + } + free(addr); - return res; + return res; } void nl_lookup_ip(NIDList nl)