Whamcloud - gitweb
LU-6153 libcfs: rename cfs_snprintf() to scnprintf()
[fs/lustre-release.git] / libcfs / libcfs / libcfs_string.c
index 0d26580..2a3009f 100644 (file)
@@ -139,54 +139,6 @@ int cfs_str2mask(const char *str, const char *(*bit2str)(int bit),
 }
 EXPORT_SYMBOL(cfs_str2mask);
 
-/* Duplicate a string in a platform-independent way */
-char *cfs_strdup(const char *str, u_int32_t flags)
-{
-        size_t lenz; /* length of str + zero byte */
-        char *dup_str;
-
-        lenz = strlen(str) + 1;
-
-       dup_str = kmalloc(lenz, flags);
-        if (dup_str == NULL)
-                return NULL;
-
-        memcpy(dup_str, str, lenz);
-
-        return dup_str;
-}
-EXPORT_SYMBOL(cfs_strdup);
-
-/**
- * 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)
 {
@@ -220,12 +172,12 @@ cfs_trimwhite(char *str)
 {
        char *end;
 
-       while (cfs_iswhite(*str))
+       while (isspace(*str))
                str++;
 
        end = str + strlen(str);
        while (end > str) {
-               if (!cfs_iswhite(end[-1]))
+               if (!isspace(end[-1]))
                        break;
                end--;
        }
@@ -255,7 +207,7 @@ cfs_gettok(struct cfs_lstr *next, char delim, struct cfs_lstr *res)
 
        /* skip leading white spaces */
        while (next->ls_len) {
-               if (!cfs_iswhite(*next->ls_str))
+               if (!isspace(*next->ls_str))
                        break;
                next->ls_str++;
                next->ls_len--;
@@ -282,7 +234,7 @@ cfs_gettok(struct cfs_lstr *next, char delim, struct cfs_lstr *res)
 
        /* skip ending whitespaces */
        while (--end != res->ls_str) {
-               if (!cfs_iswhite(*end))
+               if (!isspace(*end))
                        break;
        }
 
@@ -306,12 +258,12 @@ cfs_str2num_check(char *str, int nob, unsigned *num,
 {
        char    *endp;
 
-       *num = strtoul(str, &endp, 0);
+       *num = simple_strtoul(str, &endp, 0);
        if (endp == str)
                return 0;
 
        for (; endp < str + nob; endp++) {
-               if (!cfs_iswhite(*endp))
+               if (!isspace(*endp))
                        return 0;
        }
 
@@ -416,12 +368,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;
@@ -448,17 +400,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;
 }
@@ -545,7 +497,7 @@ cfs_expr_list_free(struct cfs_expr_list *expr_list)
                struct cfs_range_expr *expr;
 
                expr = list_entry(expr_list->el_exprs.next,
-                                     struct cfs_range_expr, re_link),
+                                     struct cfs_range_expr, re_link);
                list_del(&expr->re_link);
                LIBCFS_FREE(expr, sizeof(*expr));
        }
@@ -699,10 +651,3 @@ cfs_ip_addr_match(__u32 addr, struct list_head *list)
        return i == 4;
 }
 EXPORT_SYMBOL(cfs_ip_addr_match);
-
-void
-cfs_ip_addr_free(struct list_head *list)
-{
-       cfs_expr_list_free_list(list);
-}
-EXPORT_SYMBOL(cfs_ip_addr_free);