Whamcloud - gitweb
LU-8038 tests: test case for lfs migrate --block
[fs/lustre-release.git] / libcfs / libcfs / libcfs_string.c
index ebe91ac..2eb8efa 100644 (file)
@@ -27,7 +27,7 @@
  * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
  *
- * Copyright (c) 2012, 2014, Intel Corporation.
+ * Copyright (c) 2012, 2015, Intel Corporation.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
@@ -139,36 +139,6 @@ int cfs_str2mask(const char *str, const char *(*bit2str)(int bit),
 }
 EXPORT_SYMBOL(cfs_str2mask);
 
-/**
- * cfs_{v}snprintf() return the actual size that is printed rather than
- * the size that would be printed in standard functions.
- */
-/* safe vsnprintf */
-int cfs_vsnprintf(char *buf, size_t size, const char *fmt, va_list args)
-{
-        int i;
-
-        LASSERT(size > 0);
-        i = vsnprintf(buf, size, fmt, args);
-
-        return  (i >= size ? size - 1 : i);
-}
-EXPORT_SYMBOL(cfs_vsnprintf);
-
-/* safe snprintf */
-int cfs_snprintf(char *buf, size_t size, const char *fmt, ...)
-{
-        va_list args;
-        int i;
-
-        va_start(args, fmt);
-        i = cfs_vsnprintf(buf, size, fmt, args);
-        va_end(args);
-
-        return  i;
-}
-EXPORT_SYMBOL(cfs_snprintf);
-
 /* get the first string out of @str */
 char *cfs_firststr(char *str, size_t size)
 {
@@ -314,7 +284,7 @@ EXPORT_SYMBOL(cfs_str2num_check);
  * \retval 0 will be returned if it can be parsed, otherwise -EINVAL or
  * -ENOMEM will be returned.
  */
-int
+static int
 cfs_range_expr_parse(struct cfs_lstr *src, unsigned min, unsigned max,
                     int bracketed, struct cfs_range_expr **expr)
 {
@@ -377,7 +347,6 @@ cfs_range_expr_parse(struct cfs_lstr *src, unsigned min, unsigned max,
        LIBCFS_FREE(re, sizeof(*re));
        return -EINVAL;
 }
-EXPORT_SYMBOL(cfs_range_expr_parse);
 
 /**
  * Print the range expression \a re into specified \a buffer.
@@ -398,12 +367,12 @@ cfs_range_expr_print(char *buffer, int count, struct cfs_range_expr *expr,
                s[0] = e[0] = '\0';
 
        if (expr->re_lo == expr->re_hi)
-               i = cfs_snprintf(buffer, count, "%u", expr->re_lo);
+               i = scnprintf(buffer, count, "%u", expr->re_lo);
        else if (expr->re_stride == 1)
-               i = cfs_snprintf(buffer, count, "%s%u-%u%s",
+               i = scnprintf(buffer, count, "%s%u-%u%s",
                                  s, expr->re_lo, expr->re_hi, e);
        else
-               i = cfs_snprintf(buffer, count, "%s%u-%u/%u%s",
+               i = scnprintf(buffer, count, "%s%u-%u/%u%s",
                                  s, expr->re_lo, expr->re_hi,
                                  expr->re_stride, e);
        return i;
@@ -430,17 +399,17 @@ cfs_expr_list_print(char *buffer, int count, struct cfs_expr_list *expr_list)
                numexprs++;
 
        if (numexprs > 1)
-               i += cfs_snprintf(buffer + i, count - i, "[");
+               i += scnprintf(buffer + i, count - i, "[");
 
        list_for_each_entry(expr, &expr_list->el_exprs, re_link) {
                if (j++ != 0)
-                       i += cfs_snprintf(buffer + i, count - i, ",");
+                       i += scnprintf(buffer + i, count - i, ",");
                i += cfs_range_expr_print(buffer + i, count - i, expr,
                                          numexprs > 1);
        }
 
        if (numexprs > 1)
-               i += cfs_snprintf(buffer + i, count - i, "]");
+               i += scnprintf(buffer + i, count - i, "]");
 
        return i;
 }
@@ -619,65 +588,3 @@ cfs_expr_list_free_list(struct list_head *list)
        }
 }
 EXPORT_SYMBOL(cfs_expr_list_free_list);
-
-int
-cfs_ip_addr_parse(char *str, int len, struct list_head *list)
-{
-       struct cfs_expr_list    *el;
-       struct cfs_lstr         src;
-       int                     rc;
-       int                     i;
-
-       src.ls_str = str;
-       src.ls_len = len;
-       i = 0;
-
-       while (src.ls_str != NULL) {
-               struct cfs_lstr res;
-
-               if (!cfs_gettok(&src, '.', &res)) {
-                       rc = -EINVAL;
-                       goto out;
-               }
-
-               rc = cfs_expr_list_parse(res.ls_str, res.ls_len, 0, 255, &el);
-               if (rc != 0)
-                       goto out;
-
-               list_add_tail(&el->el_link, list);
-               i++;
-       }
-
-       if (i == 4)
-               return 0;
-
-       rc = -EINVAL;
- out:
-       cfs_expr_list_free_list(list);
-
-       return rc;
-}
-EXPORT_SYMBOL(cfs_ip_addr_parse);
-
-/**
- * Matches address (\a addr) against address set encoded in \a list.
- *
- * \retval 1 if \a addr matches
- * \retval 0 otherwise
- */
-int
-cfs_ip_addr_match(__u32 addr, struct list_head *list)
-{
-       struct cfs_expr_list *el;
-       int i = 0;
-
-       list_for_each_entry_reverse(el, list, el_link) {
-               if (!cfs_expr_list_match(addr & 0xff, el))
-                       return 0;
-               addr >>= 8;
-               i++;
-       }
-
-       return i == 4;
-}
-EXPORT_SYMBOL(cfs_ip_addr_match);