diff options
author | André Goddard Rosa <andre.goddard@gmail.com> | 2009-12-14 21:00:58 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-12-15 11:53:29 -0500 |
commit | 08562cb27da6a1472be15898173105b46801a73b (patch) | |
tree | 738e298e14771b9cf3e98389f2c0ae776f396165 /lib | |
parent | 7b9186f5eb0b1705abf7b2fbf33076a6b83f9d89 (diff) |
vsprintf: use TOLOWER whenever possible
It decreases code size as well:
text data bss dec hex filename
15758 0 8 15766 3d96 vsprintf.o (ex lib/lib.a-BEFORE)
15726 0 8 15734 3d76 vsprintf.o (ex lib/lib.a-TOLOWER)
Signed-off-by: André Goddard Rosa <andre.goddard@gmail.com>
Acked-by: Frederic Weisbecker <fweisbec@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/vsprintf.c | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/lib/vsprintf.c b/lib/vsprintf.c index 2e1dda2b549d..cba2385a6f0b 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c | |||
@@ -1034,8 +1034,8 @@ precision: | |||
1034 | qualifier: | 1034 | qualifier: |
1035 | /* get the conversion qualifier */ | 1035 | /* get the conversion qualifier */ |
1036 | spec->qualifier = -1; | 1036 | spec->qualifier = -1; |
1037 | if (*fmt == 'h' || *fmt == 'l' || *fmt == 'L' || | 1037 | if (*fmt == 'h' || TOLOWER(*fmt) == 'l' || |
1038 | *fmt == 'Z' || *fmt == 'z' || *fmt == 't') { | 1038 | TOLOWER(*fmt) == 'z' || *fmt == 't') { |
1039 | spec->qualifier = *fmt++; | 1039 | spec->qualifier = *fmt++; |
1040 | if (unlikely(spec->qualifier == *fmt)) { | 1040 | if (unlikely(spec->qualifier == *fmt)) { |
1041 | if (spec->qualifier == 'l') { | 1041 | if (spec->qualifier == 'l') { |
@@ -1102,7 +1102,7 @@ qualifier: | |||
1102 | spec->type = FORMAT_TYPE_LONG; | 1102 | spec->type = FORMAT_TYPE_LONG; |
1103 | else | 1103 | else |
1104 | spec->type = FORMAT_TYPE_ULONG; | 1104 | spec->type = FORMAT_TYPE_ULONG; |
1105 | } else if (spec->qualifier == 'Z' || spec->qualifier == 'z') { | 1105 | } else if (TOLOWER(spec->qualifier) == 'z') { |
1106 | spec->type = FORMAT_TYPE_SIZE_T; | 1106 | spec->type = FORMAT_TYPE_SIZE_T; |
1107 | } else if (spec->qualifier == 't') { | 1107 | } else if (spec->qualifier == 't') { |
1108 | spec->type = FORMAT_TYPE_PTRDIFF; | 1108 | spec->type = FORMAT_TYPE_PTRDIFF; |
@@ -1249,8 +1249,7 @@ int vsnprintf(char *buf, size_t size, const char *fmt, va_list args) | |||
1249 | if (qualifier == 'l') { | 1249 | if (qualifier == 'l') { |
1250 | long *ip = va_arg(args, long *); | 1250 | long *ip = va_arg(args, long *); |
1251 | *ip = (str - buf); | 1251 | *ip = (str - buf); |
1252 | } else if (qualifier == 'Z' || | 1252 | } else if (TOLOWER(qualifier) == 'z') { |
1253 | qualifier == 'z') { | ||
1254 | size_t *ip = va_arg(args, size_t *); | 1253 | size_t *ip = va_arg(args, size_t *); |
1255 | *ip = (str - buf); | 1254 | *ip = (str - buf); |
1256 | } else { | 1255 | } else { |
@@ -1540,7 +1539,7 @@ do { \ | |||
1540 | void *skip_arg; | 1539 | void *skip_arg; |
1541 | if (qualifier == 'l') | 1540 | if (qualifier == 'l') |
1542 | skip_arg = va_arg(args, long *); | 1541 | skip_arg = va_arg(args, long *); |
1543 | else if (qualifier == 'Z' || qualifier == 'z') | 1542 | else if (TOLOWER(qualifier) == 'z') |
1544 | skip_arg = va_arg(args, size_t *); | 1543 | skip_arg = va_arg(args, size_t *); |
1545 | else | 1544 | else |
1546 | skip_arg = va_arg(args, int *); | 1545 | skip_arg = va_arg(args, int *); |
@@ -1851,8 +1850,8 @@ int vsscanf(const char *buf, const char *fmt, va_list args) | |||
1851 | 1850 | ||
1852 | /* get conversion qualifier */ | 1851 | /* get conversion qualifier */ |
1853 | qualifier = -1; | 1852 | qualifier = -1; |
1854 | if (*fmt == 'h' || *fmt == 'l' || *fmt == 'L' || | 1853 | if (*fmt == 'h' || TOLOWER(*fmt) == 'l' || |
1855 | *fmt == 'Z' || *fmt == 'z') { | 1854 | TOLOWER(*fmt) == 'z') { |
1856 | qualifier = *fmt++; | 1855 | qualifier = *fmt++; |
1857 | if (unlikely(qualifier == *fmt)) { | 1856 | if (unlikely(qualifier == *fmt)) { |
1858 | if (qualifier == 'h') { | 1857 | if (qualifier == 'h') { |