diff options
author | André Goddard Rosa <andre.goddard@gmail.com> | 2009-12-14 21:00:55 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-12-15 11:53:29 -0500 |
commit | 0f4f81dce93774a447da3ceb98cce193ef84a3fa (patch) | |
tree | 343f83bc9ed704d57f462a729eb91b100edff0c0 /lib | |
parent | 3768f0b1d18369bbb4ddc3adca791d26704e8047 (diff) |
vsprintf: factorize "(null)" string
This patchset reduces lib/lib.a code size by 482 bytes on my Core 2 with
gcc 4.4.1 even considering that it exports a newly defined function
skip_spaces() to drivers:
text data bss dec hex filename
64867 840 592 66299 102fb (TOTALS-lib.a-BEFORE)
64641 584 592 65817 10119 (TOTALS-lib.a-AFTER)
and implements some code tidy up.
Besides reducing lib.a size, it converts many in-tree drivers to use the
newly defined function, which makes another small reduction on kernel size
overall when those drivers are used.
This patch:
Change "<NULL>" to "(null)", unifying 3 equal strings.
glibc also uses "(null)" for the same purpose.
It decreases code size by 7 bytes:
text data bss dec hex filename
15765 0 8 15773 3d9d vsprintf.o (ex lib/lib.a-BEFORE)
15758 0 8 15766 3d96 vsprintf.o (ex lib/lib.a-AFTER)
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 | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/vsprintf.c b/lib/vsprintf.c index 6438cd5599ee..e5ab51fc2d9e 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c | |||
@@ -546,12 +546,12 @@ static char *number(char *buf, char *end, unsigned long long num, | |||
546 | return buf; | 546 | return buf; |
547 | } | 547 | } |
548 | 548 | ||
549 | static char *string(char *buf, char *end, char *s, struct printf_spec spec) | 549 | static char *string(char *buf, char *end, const char *s, struct printf_spec spec) |
550 | { | 550 | { |
551 | int len, i; | 551 | int len, i; |
552 | 552 | ||
553 | if ((unsigned long)s < PAGE_SIZE) | 553 | if ((unsigned long)s < PAGE_SIZE) |
554 | s = "<NULL>"; | 554 | s = "(null)"; |
555 | 555 | ||
556 | len = strnlen(s, spec.precision); | 556 | len = strnlen(s, spec.precision); |
557 | 557 | ||
@@ -1498,7 +1498,7 @@ do { \ | |||
1498 | size_t len; | 1498 | size_t len; |
1499 | if ((unsigned long)save_str > (unsigned long)-PAGE_SIZE | 1499 | if ((unsigned long)save_str > (unsigned long)-PAGE_SIZE |
1500 | || (unsigned long)save_str < PAGE_SIZE) | 1500 | || (unsigned long)save_str < PAGE_SIZE) |
1501 | save_str = "<NULL>"; | 1501 | save_str = "(null)"; |
1502 | len = strlen(save_str); | 1502 | len = strlen(save_str); |
1503 | if (str + len + 1 < end) | 1503 | if (str + len + 1 < end) |
1504 | memcpy(str, save_str, len + 1); | 1504 | memcpy(str, save_str, len + 1); |