aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorJoe Perches <joe@perches.com>2010-03-06 20:10:14 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2010-03-06 20:47:45 -0500
commitef0658f3de484bf9b173639cd47544584e01efa5 (patch)
treed9d6c569b2c79fb9cf240783a409722cc9264886 /lib
parent7bc80cd935a4d5fd8574f6994bd95d0aad273d56 (diff)
vsprintf.c: Reduce sizeof struct printf_spec from 24 to 8 bytes
Reducing the size of struct printf_spec is a good thing because multiple instances are commonly passed on stack. It's possible for type to be u8 and field_width to be s8, but this is likely small enough for now. Signed-off-by: Joe Perches <joe@perches.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'lib')
-rw-r--r--lib/vsprintf.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/lib/vsprintf.c b/lib/vsprintf.c
index af4aaa6c36f3..e994cea385c8 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -408,12 +408,12 @@ enum format_type {
408}; 408};
409 409
410struct printf_spec { 410struct printf_spec {
411 enum format_type type; 411 u16 type;
412 int flags; /* flags to number() */ 412 s16 field_width; /* width of output field */
413 int field_width; /* width of output field */ 413 u8 flags; /* flags to number() */
414 int base; 414 u8 base;
415 int precision; /* # of digits/chars */ 415 s8 precision; /* # of digits/chars */
416 int qualifier; 416 u8 qualifier;
417}; 417};
418 418
419static char *number(char *buf, char *end, unsigned long long num, 419static char *number(char *buf, char *end, unsigned long long num,
@@ -1333,7 +1333,7 @@ int vsnprintf(char *buf, size_t size, const char *fmt, va_list args)
1333 break; 1333 break;
1334 1334
1335 case FORMAT_TYPE_NRCHARS: { 1335 case FORMAT_TYPE_NRCHARS: {
1336 int qualifier = spec.qualifier; 1336 u8 qualifier = spec.qualifier;
1337 1337
1338 if (qualifier == 'l') { 1338 if (qualifier == 'l') {
1339 long *ip = va_arg(args, long *); 1339 long *ip = va_arg(args, long *);
@@ -1619,7 +1619,7 @@ do { \
1619 1619
1620 case FORMAT_TYPE_NRCHARS: { 1620 case FORMAT_TYPE_NRCHARS: {
1621 /* skip %n 's argument */ 1621 /* skip %n 's argument */
1622 int qualifier = spec.qualifier; 1622 u8 qualifier = spec.qualifier;
1623 void *skip_arg; 1623 void *skip_arg;
1624 if (qualifier == 'l') 1624 if (qualifier == 'l')
1625 skip_arg = va_arg(args, long *); 1625 skip_arg = va_arg(args, long *);
@@ -1885,7 +1885,9 @@ int vsscanf(const char *buf, const char *fmt, va_list args)
1885 char *next; 1885 char *next;
1886 char digit; 1886 char digit;
1887 int num = 0; 1887 int num = 0;
1888 int qualifier, base, field_width; 1888 u8 qualifier;
1889 u8 base;
1890 s16 field_width;
1889 bool is_sign; 1891 bool is_sign;
1890 1892
1891 while (*fmt && *str) { 1893 while (*fmt && *str) {
@@ -1963,7 +1965,7 @@ int vsscanf(const char *buf, const char *fmt, va_list args)
1963 { 1965 {
1964 char *s = (char *)va_arg(args, char *); 1966 char *s = (char *)va_arg(args, char *);
1965 if (field_width == -1) 1967 if (field_width == -1)
1966 field_width = INT_MAX; 1968 field_width = SHORT_MAX;
1967 /* first, skip leading white space in buffer */ 1969 /* first, skip leading white space in buffer */
1968 str = skip_spaces(str); 1970 str = skip_spaces(str);
1969 1971