From: John L. Hammond Date: Mon, 23 Mar 2015 15:23:15 +0000 (-0400) Subject: LU-6153 libcfs: rename cfs_snprintf() to scnprintf() X-Git-Tag: 2.7.52~10 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=6c0fa97869b568a7af2d21e7e4ed2b440b7dfa27 LU-6153 libcfs: rename cfs_snprintf() to scnprintf() Rename cfs_snprintf() to scnprintf() to match the existing kernel function. Similarly rename cfs_vsnprintf() to vscnprintf(). Remove the unused functions cfs_[v]snprintf(). Signed-off-by: John L. Hammond Change-Id: I361a28959dc8a20ab0e152eaed00fd4adf78cc34 Reviewed-on: http://review.whamcloud.com/13517 Reviewed-by: Andreas Dilger Tested-by: Jenkins Reviewed-by: Dmitry Eremin Tested-by: Maloo Reviewed-by: James Simmons --- diff --git a/libcfs/include/libcfs/libcfs_string.h b/libcfs/include/libcfs/libcfs_string.h index 238be35..53493b3 100644 --- a/libcfs/include/libcfs/libcfs_string.h +++ b/libcfs/include/libcfs/libcfs_string.h @@ -48,13 +48,6 @@ char *cfs_strrstr(const char *haystack, const char *needle); /* Convert a text string to a bitmask */ int cfs_str2mask(const char *str, const char *(*bit2str)(int bit), int *oldmask, int minmask, int allmask); - -/* safe vsnprintf */ -int cfs_vsnprintf(char *buf, size_t size, const char *fmt, va_list args); - -/* safe snprintf */ -int cfs_snprintf(char *buf, size_t size, const char *fmt, ...); - /* trim leading and trailing space characters */ char *cfs_firststr(char *str, size_t size); diff --git a/libcfs/libcfs/libcfs_string.c b/libcfs/libcfs/libcfs_string.c index ebe91ac..2a3009f 100644 --- a/libcfs/libcfs/libcfs_string.c +++ b/libcfs/libcfs/libcfs_string.c @@ -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) { @@ -398,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; @@ -430,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; } diff --git a/lnet/lnet/nidstrings.c b/lnet/lnet/nidstrings.c index 2474445..8f3236d 100644 --- a/lnet/lnet/nidstrings.c +++ b/lnet/lnet/nidstrings.c @@ -941,7 +941,7 @@ libcfs_ip_addr_range_print(char *buffer, int count, struct list_head *list) list_for_each_entry(el, list, el_link) { LASSERT(j++ < 4); if (i != 0) - i += cfs_snprintf(buffer + i, count - i, "."); + i += scnprintf(buffer + i, count - i, "."); i += cfs_expr_list_print(buffer + i, count - i, el); } return i; @@ -959,9 +959,9 @@ cfs_print_network(char *buffer, int count, struct nidrange *nr) struct netstrfns *nf = nr->nr_netstrfns; if (nr->nr_netnum == 0) - return cfs_snprintf(buffer, count, "@%s", nf->nf_name); + return scnprintf(buffer, count, "@%s", nf->nf_name); else - return cfs_snprintf(buffer, count, "@%s%u", + return scnprintf(buffer, count, "@%s%u", nf->nf_name, nr->nr_netnum); } @@ -982,7 +982,7 @@ cfs_print_addrranges(char *buffer, int count, struct list_head *addrranges, list_for_each_entry(ar, addrranges, ar_link) { if (i != 0) - i += cfs_snprintf(buffer + i, count - i, " "); + i += scnprintf(buffer + i, count - i, " "); i += nf->nf_print_addrlist(buffer + i, count - i, &ar->ar_numaddr_ranges); i += cfs_print_network(buffer + i, count - i, nr); @@ -1007,11 +1007,11 @@ int cfs_print_nidlist(char *buffer, int count, struct list_head *nidlist) list_for_each_entry(nr, nidlist, nr_link) { if (i != 0) - i += cfs_snprintf(buffer + i, count - i, " "); + i += scnprintf(buffer + i, count - i, " "); if (nr->nr_all != 0) { LASSERT(list_empty(&nr->nr_addrranges)); - i += cfs_snprintf(buffer + i, count - i, "*"); + i += scnprintf(buffer + i, count - i, "*"); i += cfs_print_network(buffer + i, count - i, nr); } else { i += cfs_print_addrranges(buffer + i, count - i,