[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen master] common/vsprintf: Refactor string() out of vsnprintf()
commit 67a3542c5bc356e6452d8305991617c875f87de4 Author: Andrew Cooper <andrew.cooper3@xxxxxxxxxx> AuthorDate: Tue Nov 12 11:06:09 2013 +0100 Commit: Jan Beulich <jbeulich@xxxxxxxx> CommitDate: Tue Nov 12 11:06:09 2013 +0100 common/vsprintf: Refactor string() out of vsnprintf() No functional change. Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx> Reviewed-by: Jan Beulich <jbeulich@xxxxxxxx> Acked-by: Keir Fraser <keir@xxxxxxx> --- xen/common/vsprintf.c | 49 ++++++++++++++++++++++++++++--------------------- 1 files changed, 28 insertions(+), 21 deletions(-) diff --git a/xen/common/vsprintf.c b/xen/common/vsprintf.c index 95bf85d..4211ebe 100644 --- a/xen/common/vsprintf.c +++ b/xen/common/vsprintf.c @@ -235,6 +235,32 @@ static char *number( return buf; } +static char *string(char *str, char *end, const char *s, + int field_width, int precision, int flags) +{ + unsigned int i, len = strnlen(s, precision); + + if (!(flags & LEFT)) { + while (len < field_width--) { + if (str <= end) + *str = ' '; + ++str; + } + } + for (i = 0; i < len; ++i) { + if (str <= end) + *str = *s; + ++str; ++s; + } + while (len < field_width--) { + if (str <= end) + *str = ' '; + ++str; + } + + return str; +} + /** * vsnprintf - Format a string and place it in a buffer * @buf: The buffer to place the result into @@ -255,9 +281,8 @@ static char *number( */ int vsnprintf(char *buf, size_t size, const char *fmt, va_list args) { - int len; unsigned long long num; - int i, base; + int base; char *str, *end, c; const char *s; @@ -370,25 +395,7 @@ int vsnprintf(char *buf, size_t size, const char *fmt, va_list args) if ((unsigned long)s < PAGE_SIZE) s = "<NULL>"; - len = strnlen(s, precision); - - if (!(flags & LEFT)) { - while (len < field_width--) { - if (str <= end) - *str = ' '; - ++str; - } - } - for (i = 0; i < len; ++i) { - if (str <= end) - *str = *s; - ++str; ++s; - } - while (len < field_width--) { - if (str <= end) - *str = ' '; - ++str; - } + str = string(str, end, s, field_width, precision, flags); continue; case 'p': -- generated by git-patchbot for /home/xen/git/xen.git#master _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |