Commit ef0658f3 authored by Joe Perches's avatar Joe Perches Committed by Linus Torvalds

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: default avatarJoe Perches <joe@perches.com>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 7bc80cd9
...@@ -408,12 +408,12 @@ enum format_type { ...@@ -408,12 +408,12 @@ enum format_type {
}; };
struct printf_spec { struct printf_spec {
enum format_type type; u16 type;
int flags; /* flags to number() */ s16 field_width; /* width of output field */
int field_width; /* width of output field */ u8 flags; /* flags to number() */
int base; u8 base;
int precision; /* # of digits/chars */ s8 precision; /* # of digits/chars */
int qualifier; u8 qualifier;
}; };
static char *number(char *buf, char *end, unsigned long long num, static 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,7 +1333,7 @@ int vsnprintf(char *buf, size_t size, const char *fmt, va_list args)
break; break;
case FORMAT_TYPE_NRCHARS: { case FORMAT_TYPE_NRCHARS: {
int qualifier = spec.qualifier; u8 qualifier = spec.qualifier;
if (qualifier == 'l') { if (qualifier == 'l') {
long *ip = va_arg(args, long *); long *ip = va_arg(args, long *);
...@@ -1619,7 +1619,7 @@ do { \ ...@@ -1619,7 +1619,7 @@ do { \
case FORMAT_TYPE_NRCHARS: { case FORMAT_TYPE_NRCHARS: {
/* skip %n 's argument */ /* skip %n 's argument */
int qualifier = spec.qualifier; u8 qualifier = spec.qualifier;
void *skip_arg; void *skip_arg;
if (qualifier == 'l') if (qualifier == 'l')
skip_arg = va_arg(args, long *); skip_arg = va_arg(args, long *);
...@@ -1885,7 +1885,9 @@ int vsscanf(const char *buf, const char *fmt, va_list args) ...@@ -1885,7 +1885,9 @@ int vsscanf(const char *buf, const char *fmt, va_list args)
char *next; char *next;
char digit; char digit;
int num = 0; int num = 0;
int qualifier, base, field_width; u8 qualifier;
u8 base;
s16 field_width;
bool is_sign; bool is_sign;
while (*fmt && *str) { while (*fmt && *str) {
...@@ -1963,7 +1965,7 @@ int vsscanf(const char *buf, const char *fmt, va_list args) ...@@ -1963,7 +1965,7 @@ int vsscanf(const char *buf, const char *fmt, va_list args)
{ {
char *s = (char *)va_arg(args, char *); char *s = (char *)va_arg(args, char *);
if (field_width == -1) if (field_width == -1)
field_width = INT_MAX; field_width = SHORT_MAX;
/* first, skip leading white space in buffer */ /* first, skip leading white space in buffer */
str = skip_spaces(str); str = skip_spaces(str);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment