Whamcloud - gitweb
LU-15220 utils: use 'fallthrough' pseudo keyword for switch
[fs/lustre-release.git] / lustre / utils / nidlist.c
index e9ff697..3af3c30 100644 (file)
@@ -22,6 +22,8 @@
 /*
  * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
+ *
+ * Copyright (c) 2014, Intel Corporation.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
@@ -260,9 +262,9 @@ char *nl_string(NIDList nl, char *sep)
                nl_oom();
        s[0] = '\0';
        for (i = 0; i < nl->count; i++) {
-               if (i > 0)
-                       strncat(s, sep, len);
-               strncat(s, nl->nids[i], len);
+               int cur = strlen(s);
+               snprintf(s + cur, len - cur, "%s%s",
+                        i > 0 ? sep : "", nl->nids[i]);
        }
        return s;
 }
@@ -310,7 +312,7 @@ static void nl_strxcat(char *s, char **nids, int len, const int max_len)
                                         "-%s", savedn);
                                free(savedn);
                        }
-                       strncat(s, "]", 1);
+                       strncat(s, "]", max_len - strlen(s));
                        if (lnet)
                                snprintf(s + strlen(s), max_len - strlen(s),
                                         "@%s", lnet);