12 Jan, 2010
1 commit
-
Signed-off-by: Uwe Kleine-König
Reported-by: Josip Rodin
Cc: Joe Perches
Cc: David S. Miller
Signed-off-by: Andrew Morton
Signed-off-by: Linus Torvalds
18 Dec, 2009
1 commit
-
These were added in
9ac6e44 (lib/vsprintf.c: add %pU to print UUID/GUIDs)
c7dabef (vsprintf: use %pR, %pr instead of %pRt, %pRf)
8a27f7c (lib/vsprintf.c: Add "%pI6c" - print pointer as compressed ipv6 address)
4aa9960 (printk: add %I4, %I6, %i4, %i6 format specifiers)
dd45c9c (printk: add %pM format specifier for MAC addresses)but only added comments to pointer() not vsnprintf() that is refered to by
printk's comments.Signed-off-by: Uwe Kleine-König
Cc: Harvey Harrison
Cc: David S. Miller
Cc: Joe Perches
Cc: Jens Rosenboom
Cc: David S. Miller
Cc: Bjorn Helgaas
Cc: Jesse Barnes
Signed-off-by: Andrew Morton
Signed-off-by: Linus Torvalds
16 Dec, 2009
10 commits
-
UUID/GUIDs are somewhat common in kernel source.
Standardize the printed style of UUID/GUIDs by using
another extension to %p.%pUb: 01020304-0506-0708-090a-0b0c0d0e0f10
%pUB: 01020304-0506-0708-090A-0B0C0D0E0F10 (upper case)
%pUl: 04030201-0605-0807-090a-0b0c0d0e0f10
%pUL: 04030201-0605-0807-090A-0B0C0D0E0F10 (upper case)%pU defaults to %pUb
Signed-off-by: Joe Perches
Cc: Jeff Garzik
Cc: Tejun Heo
Cc: Alex Elder
Cc: Christoph Hellwig
Cc: Artem Bityutskiy
Cc: Adrian Hunter
Cc: Steven Whitehouse
Cc: Mauro Carvalho Chehab
Cc: Matt Mackall
Cc: Neil Brown
Signed-off-by: Andrew Morton
Signed-off-by: Linus Torvalds -
Makes use of skip_spaces() defined in lib/string.c for removing leading
spaces from strings all over the tree.It decreases lib.a code size by 47 bytes and reuses the function tree-wide:
text data bss dec hex filename
64688 584 592 65864 10148 (TOTALS-BEFORE)
64641 584 592 65817 10119 (TOTALS-AFTER)Also, while at it, if we see (*str && isspace(*str)), we can be sure to
remove the first condition (*str) as the second one (isspace(*str)) also
evaluates to 0 whenever *str == 0, making it redundant. In other words,
"a char equals zero is never a space".Julia Lawall tried the semantic patch (http://coccinelle.lip6.fr) below,
and found occurrences of this pattern on 3 more files:
drivers/leds/led-class.c
drivers/leds/ledtrig-timer.c
drivers/video/output.c@@
expression str;
@@( // ignore skip_spaces cases
while (*str && isspace(*str)) { \(str++;\|++str;\) }
|
- *str &&
isspace(*str)
)Signed-off-by: André Goddard Rosa
Cc: Julia Lawall
Cc: Martin Schwidefsky
Cc: Jeff Dike
Cc: Ingo Molnar
Cc: Thomas Gleixner
Cc: "H. Peter Anvin"
Cc: Richard Purdie
Cc: Neil Brown
Cc: Kyle McMartin
Cc: Henrique de Moraes Holschuh
Cc: David Howells
Cc:
Cc: Samuel Ortiz
Cc: Patrick McHardy
Cc: Takashi Iwai
Signed-off-by: Andrew Morton
Signed-off-by: Linus Torvalds -
The difference between simple_strtoul() and simple_strtoull() is just
the size of the variable used to keep track of the sum of characters
converted to numbers:unsigned long simple_strtoul() {...}
unsigned long long simple_strtoull(){...}Both are same size on my Core 2/gcc 4.4.1.
Overflow condition is not checked on both functions, so an extremely large
string can break these functions so that they don't even notice it.As we do not care for overflowing on these functions, always keep the sum
using the larger variable around (unsigned long long) on simple_strtoull()
and cast it to (unsigned long) on simple_strtoul(), which then becomes
just a wrapper around simple_strtoull().Code size decreases by 304 bytes:
text data bss dec hex filename
15534 0 8 15542 3cb6 vsprintf.o (ex lib/lib.a-BEFORE)
15230 0 8 15238 3b86 vsprintf.o (ex lib/lib.a-AFTER)Signed-off-by: André Goddard Rosa
Signed-off-by: Andrew Morton
Signed-off-by: Linus Torvalds -
When converting more caller sites, the inline decision will be left up to gcc.
It decreases code size:
text data bss dec hex filename
15710 0 8 15718 3d66 vsprintf.o (ex lib/lib.a-BEFORE)
15534 0 8 15542 3cb6 vsprintf.o (ex lib/lib.a-AFTER)Signed-off-by: André Goddard Rosa
Acked-by: Frederic Weisbecker
Signed-off-by: Andrew Morton
Signed-off-by: Linus Torvalds -
Cleanup by moving variables closer to the scope where they're used in fact.
Also, remove unneeded ones.Signed-off-by: André Goddard Rosa
Acked-by: Frederic Weisbecker
Signed-off-by: Andrew Morton
Signed-off-by: Linus Torvalds -
No functional change, just refactor the code so that it avoid checking
"if (hi)" two times in a sequence, taking advantage of previous check made.It also reduces code size:
text data bss dec hex filename
15726 0 8 15734 3d76 vsprintf.o (ex lib/lib.a-BEFORE)
15710 0 8 15718 3d66 vsprintf.o (ex lib/lib.a-AFTER)Signed-off-by: André Goddard Rosa
Acked-by: Frederic Weisbecker
Signed-off-by: Andrew Morton
Signed-off-by: Linus Torvalds -
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
Acked-by: Frederic Weisbecker
Signed-off-by: Andrew Morton
Signed-off-by: Linus Torvalds -
Most relevant complaints were addressed.
Signed-off-by: André Goddard Rosa
Acked-by: Frederic Weisbecker
Signed-off-by: Andrew Morton
Signed-off-by: Linus Torvalds -
Signed-off-by: André Goddard Rosa
Acked-by: Frederic Weisbecker
Signed-off-by: Andrew Morton
Signed-off-by: Linus Torvalds -
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 "" 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
Acked-by: Frederic Weisbecker
Signed-off-by: Andrew Morton
Signed-off-by: Linus Torvalds
05 Nov, 2009
4 commits
-
Jesse accidentally applied v1 [1] of the patchset instead of v2 [2]. This
is the diff between v1 and v2.The changes in this patch are:
- tidied vsprintf stack buffer to shrink and compute size more
accurately
- use %pR for decoding and %pr for "raw" (with type and flags) instead
of adding %pRt and %pRf[1] http://lkml.org/lkml/2009/10/6/491
[2] http://lkml.org/lkml/2009/10/13/441Signed-off-by: Bjorn Helgaas
Signed-off-by: Jesse Barnes -
This adds support for printing struct resource type and flag information.
For example, "%pRt" looks like "[mem 0x80080000000-0x8008001ffff 64bit pref]",
and "%pRf" looks like "[mem 0xff5e2000-0xff5e2007 pref flags 0x1]".Signed-off-by: Bjorn Helgaas
Signed-off-by: Jesse Barnes -
Print addresses (IO port numbers and memory addresses) in hex, but print
others (IRQs and DMA channels) in decimal. Only print the end if it's
different from the start.Signed-off-by: Bjorn Helgaas
Signed-off-by: Jesse Barnes -
The leading "0x" consumes field width, so leave space for it in addition to
the 4 or 8 hex digits. This means we'll print "0x0000-0x01df" rather than
"0x00-0x1df", for example.Signed-off-by: Bjorn Helgaas
Signed-off-by: Jesse Barnes
02 Oct, 2009
1 commit
-
When using %*s, sscanf should honor conversion specifiers immediately
following the %*s. For example, the following code should find the
position of the end of the string "hello".int end;
char buf[] = "hello world";
sscanf(buf, "%*s%n", &end);
printf("%d\n", end);Ideally, sscanf would advance the fmt and str pointers the same as it
would without the *, but the code for that is rather complicated and is
not included in the patch.Signed-off-by: Andy Spencer
Acked-by: WANG Cong
Signed-off-by: Andrew Morton
Signed-off-by: Linus Torvalds
25 Sep, 2009
1 commit
-
Conflicts:
drivers/staging/Kconfig
drivers/staging/Makefile
drivers/staging/cpc-usb/TODO
drivers/staging/cpc-usb/cpc-usb_drv.c
drivers/staging/cpc-usb/cpc.h
drivers/staging/cpc-usb/cpc_int.h
drivers/staging/cpc-usb/cpcusb.h
23 Sep, 2009
1 commit
-
Jens Rosenboom noticed that a possibly unaligned const char*
is cast to a const struct in6_addr *.Avoid this at the cost of a struct in6_addr copy on the stack.
Signed-off-by: Joe Perches
Signed-off-by: David S. Miller
22 Sep, 2009
1 commit
-
Signed-off-by: Marcin Slusarz
Reviewed-by: Frederic Weisbecker
Signed-off-by: Andrew Morton
Signed-off-by: Linus Torvalds
18 Sep, 2009
2 commits
-
Remove the duplicate comment of bstr_printf that is the same as the
vsnprintf.Add the 's' option to the comment for the pointer function. This is
more of an internal function so the little duplication of the comment
here is OK.Reported-by: Zhaolei
Cc: Linus Torvalds
Signed-off-by: Steven Rostedt -
On PowerPC64 function pointers do not point directly at the functions,
but instead point to pointers to the functions. The output of %pF expects
to point to a pointer to the function, whereas %pS will show the function
itself.mcount returns the direct pointer to the function and not the pointer to
the pointer. Thus %pS must be used to show this. The function tracer
requires printing of the functions without offsets and uses the %pf
instead.%pF produces run_local_timers+0x4/0x1f
%pf produces just run_local_timersFor PowerPC64, we need to use the direct pointer, and we only have
%pS which will produce .run_local_timers+0x4/0x1fThis patch creates a %ps that matches the %pf as %pS matches %pF.
Cc: Linus Torvalds
Cc: Zhao Lei
Acked-by: Benjamin Herrenschmidt
Signed-off-by: Steven Rostedt
29 Aug, 2009
1 commit
-
Signed-off-by: Joe Perches
Tested-by: Jens Rosenboom
Signed-off-by: David S. Miller
30 Apr, 2009
1 commit
-
A printf format specifier which would allow us to print a pure
function name has been suggested by Andrew Morton a couple of
months ago.The current %pF is very convenient to print a function symbol,
but often we only want to print the name of the function, without
its asm offset.That's what %pf does in this patch. The lowecase f has been chosen
for its intuitive meaning of a 'weak kind of %pF'.The support for this new format would be welcome by the tracing code
where the need to print pure function names is often needed. This is
also true for other parts of the kernel:$ git-grep -E "kallsyms_lookup\(.+?\)"
arch/blackfin/kernel/traps.c: symname = kallsyms_lookup(address, &symsize, &offset, &modname, namebuf);
arch/powerpc/xmon/xmon.c: name = kallsyms_lookup(pc, &size, &offset, NULL, tmpstr);
arch/sh/kernel/cpu/sh5/unwind.c: sym = kallsyms_lookup(pc, NULL, &offset, NULL, namebuf);
arch/x86/kernel/ftrace.c: kallsyms_lookup((unsigned long) syscall, NULL, NULL, NULL, str);
kernel/kprobes.c: sym = kallsyms_lookup((unsigned long)p->addr, NULL,
kernel/lockdep.c: return kallsyms_lookup((unsigned long)key, NULL, NULL, NULL, str);
kernel/trace/ftrace.c: kallsyms_lookup(rec->ip, NULL, NULL, NULL, str);
kernel/trace/ftrace.c: kallsyms_lookup(rec->ip, NULL, NULL, NULL, str);
kernel/trace/ftrace.c: kallsyms_lookup((unsigned long)rec->ops->func, NULL, NULL, NULL, str);
kernel/trace/ftrace.c: kallsyms_lookup(rec->ip, NULL, NULL, NULL, str);
kernel/trace/ftrace.c: kallsyms_lookup(rec->ip, NULL, NULL, NULL, str);
kernel/trace/ftrace.c: kallsyms_lookup(rec->ip, NULL, NULL, &modname, str);
kernel/trace/ftrace.c: kallsyms_lookup(*ptr, NULL, NULL, NULL, str);
kernel/trace/trace_functions.c: kallsyms_lookup(ip, NULL, NULL, NULL, str);
kernel/trace/trace_output.c: kallsyms_lookup(address, NULL, NULL, NULL, str);Changes in v2:
- Add the explanation of the %pf role for vsnprintf() and bstr_printf()
- Change the comments by dropping the "asm offset" notion and only
define the %pf against the actual function offset notion.Signed-off-by: Frederic Weisbecker
Acked-by: Mike Frysinger
Cc: Linus Torvalds
Cc: Zhaolei
Cc: Tom Zanussi
Cc: Li Zefan
Cc: Andrew Morton
Cc: Steven Rostedt
LKML-Reference:
Signed-off-by: Ingo Molnar
08 Apr, 2009
2 commits
-
Impact: new feature, extend vsprintf format strings
hh is used as length modifier for signed char or unsigned char.
It is supported by glibc, we add kernel support now.Signed-off-by: Zhao Lei
Acked-by: Lai Jiangshan
Acked-by: Frederic Weisbecker
Cc: torvalds@linux-foundation.org
Cc: Steven Rostedt
LKML-Reference:
Signed-off-by: Ingo Molnar -
printk("%Q");
Output before patch: %QQ
Output after patch: %QSigned-off-by: Zhao Lei
Acked-by: Lai Jiangshan
Acked-by: Frederic Weisbecker
Cc: torvalds@linux-foundation.org
Cc: Steven Rostedt
LKML-Reference:
Signed-off-by: Ingo Molnar
14 Mar, 2009
2 commits
-
Impact: cleanup
Rename FORMAT_TYPE_WITDH
to => FORMAT_TYPE_WIDTHCc: Frederic Weisbecker
Cc: Jeremy Fitzhardinge
Signed-off-by: Ingo Molnar -
Jeremy Fitzhardinge reported:
> Change fef20d9c1380f04ba9492d6463148db07b413708, "vsprintf:
> unify the format decoding layer for its 3 users", causes a
> regression in xenbus which results in no devices getting
> attached to a new domain.%.*s is broken - fix it.
Reported-by: Jeremy Fitzhardinge
Cc: Frederic Weisbecker
Cc: Linus Torvalds
Signed-off-by: Ingo Molnar
10 Mar, 2009
1 commit
-
Sitsofe Wheeler found and bisected that while unifying the
vsprintf format decoding in:fef20d9: vsprintf: unify the format decoding layer for its 3 users
The sign flag has been dropped out in favour of
precise types (ie: LONG/ULONG).But the format helper number() still needs this flag to keep track of
the signedness unless it will consider all numbers as unsigned.Also add an explicit cast to int (for %d) while parsing with va_arg()
to ensure the highest bit is well extended on the 64 bits number that
hosts the value in case of negative values.Reported-Bisected-Tested-by: Sitsofe Wheeler
Signed-off-by: Frederic Weisbecker
Cc: Lai Jiangshan
Cc: Steven Rostedt
Cc: Linus Torvalds
LKML-Reference:
Signed-off-by: Ingo Molnar
07 Mar, 2009
2 commits
-
An new optimization is making its way to ftrace. Its purpose is to
make trace_printk() consuming less memory and be faster.Written by Lai Jiangshan, the approach is to delay the formatting
job from tracing time to output time.Currently, a call to trace_printk() will format the whole string and
insert it into the ring buffer. Then you can read it on /debug/tracing/trace
file.The new implementation stores the address of the format string and
the binary parameters into the ring buffer, making the packet more compact
and faster to insert.
Later, when the user exports the traces, the format string is retrieved
with the binary parameters and the formatting job is eventually done.The new implementation rewrites a lot of format decoding bits from
vsnprintf() function, making now 3 differents functions to maintain
in their duplicated parts of printf format decoding bits.Suggested by Ingo Molnar, this patch tries to factorize the most
possible common bits from these functions.
The real common part between them is the format decoding. Although
they do somewhat similar jobs, their way to export or import the parameters
is very different. Thus, only the decoding layer is extracted, unless you see
other parts that could be worth factorized.Changes in V2:
- Address a suggestion from Linus to group the format_decode() parameters inside
a structure.Changes in v3:
- Address other cleanups suggested by Ingo and Linus such as passing the
printf_spec struct to the format helpers: pointer()/number()/string()
Note that this struct is passed by copy and not by address. This is to
avoid side effects because these functions often change these values and the
changes shoudn't be persistant when a callee helper returns.
It would be too risky.- Various cleanups (code alignement, switch/case instead of if/else fountains).
- Fix a bug that printed the first format specifier following a %p
Changes in v4:
- drop unapropriate const qualifier loss while casting fmt to a char *
(thanks to Vegard Nossum for having pointed this out).Signed-off-by: Frederic Weisbecker
Cc: Linus Torvalds
Acked-by: Steven Rostedt
LKML-Reference:
Signed-off-by: Ingo Molnar -
Impact: add new APIs for binary trace printk infrastructure
vbin_printf(): write args to binary buffer, string is copied
when "%s" is occurred.bstr_printf(): read from binary buffer for args and format a string
[fweisbec@gmail.com: rebase]
Signed-off-by: Lai Jiangshan
Signed-off-by: Frederic Weisbecker
Cc: Linus Torvalds
LKML-Reference:
Signed-off-by: Ingo Molnar
07 Jan, 2009
1 commit
-
It decodes "\n" as 0, which is bad, because stray echo into backlight
will turn your backlight off, etc...Signed-off-by: Pavel Machek
Cc: Yi Yang
Signed-off-by: Andrew Morton
Signed-off-by: Linus Torvalds
04 Jan, 2009
1 commit
-
Before, when we only ever printed out the pointer value itself, a NULL
pointer would never cause issues and might as well be printed out as
just its numeric value.However, with the extended %p formats, especially %pR, we might validly
want to print out resources for debugging. And sometimes they don't
even exist, and the resource pointer is just NULL. Print it out as
such, rather than oopsing.This is a more generic version of a patch done by Trent Piepho (catching
all %p cases rather than just %pR, and using "(null)" instead of
"[NULL]" to match glibc).Requested-by: Trent Piepho
Acked-by: Harvey Harrison
Signed-off-by: Linus Torvalds
25 Nov, 2008
1 commit
-
Add %pm to omit the colons when printing a mac address.
Signed-off-by: Harvey Harrison
Signed-off-by: David S. Miller
04 Nov, 2008
1 commit
-
put_dec_trunc prints the digits in reverse order and is reversed
inside number(). Continue using put_dec_trunc, but reverse each quad
in ip4_addr_string.[Noticed by Julius Volz]
Signed-off-by: Harvey Harrison
Signed-off-by: David S. Miller
30 Oct, 2008
2 commits
-
Signed-off-by: Harvey Harrison
Signed-off-by: David S. Miller -
For use in printing IPv4, or IPv6 addresses in the usual way:
%i4 and %I4 are currently equivalent and print the address in
dot-separated decimal x.x.x.x%I6 prints 16-bit network order hex with colon separators:
xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx%i6 omits the colons.
Signed-off-by: Harvey Harrison
Signed-off-by: David S. Miller
29 Oct, 2008
1 commit
-
Takes a pointer to a IPv6 address and formats it in the usual
colon-separated hex format:
xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxxEach 16 bit word is printed in network-endian byteorder.
%#p6 is also supported and will omit the colons.
%p6 is a replacement for NIP6_FMT and NIP6()
%#p6 is a replacement for NIP6_SEQFMT and NIP6()Note that NIP6() took a struct in6_addr whereas this takes a pointer
to a struct in6_addr.Signed-off-by: Harvey Harrison
Signed-off-by: David S. Miller
28 Oct, 2008
1 commit
-
Add format specifiers for printing out six colon-separated bytes:
MAC addresses (%pM):
xx:xx:xx:xx:xx:xx%#pM is also supported and omits the colon separators.
Signed-off-by: Harvey Harrison
Signed-off-by: David S. Miller
21 Oct, 2008
1 commit
-
Add a %pR option to the kernel vsnprintf that prints the range of
addresses inside a struct resource passed by pointer.Signed-off-by: Linus Torvalds
Signed-off-by: Benjamin Herrenschmidt
Signed-off-by: Linus Torvalds