aboutsummaryrefslogtreecommitdiff
path: root/lib/vsprintf.c
AgeCommit message (Collapse)AuthorFilesLines
2010-01-13lib/vsprintf.c: Add IPV4 options %pI4[hnbl] for host, network, big and ↵Joe Perches1-5/+31
little endian This should allow the removal of the #defines and uses of NIPQUAD and NIPQUAD_FMT Signed-off-by: Joe Perches <[email protected]> Signed-off-by: David S. Miller <[email protected]>
2010-01-11vsnprintf: fix reference for compressed ipv6 addressesUwe Kleine-König1-2/+2
Signed-off-by: Uwe Kleine-König <[email protected]> Reported-by: Josip Rodin <[email protected]> Cc: Joe Perches <[email protected]> Cc: David S. Miller <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2010-01-11lib: Kill bit-reversed FDDI MAC output case, it's bogus.Joe Perches1-8/+2
Signed-off-by: Joe Perches <[email protected]> Signed-off-by: David S. Miller <[email protected]>
2010-01-07lib/vsprintf.c: Add %pMF to format FDDI bit reversed MAC addressesJoe Perches1-2/+18
On Mon, 2010-01-04 at 23:43 +0000, Maciej W. Rozycki wrote: > The example below shows an address, and the sequence of bits or symbols > that would be transmitted when the address is used in the Source Address > or Destination Address fields on the MAC header. The transmission line > shows the address bits in the order transmitted, from left to right. For > IEEE 802 LANs these correspond to actual bits on the medium. The FDDI > symbols line shows how the FDDI PHY sends the address bits as encoded > symbols. > > MSB: 35:7B:12:00:00:01 > Canonical: AC-DE-48-00-00-80 > Transmission: 00110101 01111011 00010010 00000000 00000000 00000001 > FDDI Symbols: 35 7B 12 00 00 01" > > Please note that this address has its group bit clear. > > This notation is also defined in the "FDDI MEDIA ACCESS CONTROL-2 > (MAC-2)" (X3T9/92-120) document although that book does not have a need > to use the MSB form and it's skipped. Adds 6 bytes to object size for x86 New: $ size lib/vsprintf.o text data bss dec hex filename 8664 0 2 8666 21da lib/vsprintf.o $ size lib/vsprintf.o text data bss dec hex filename 8658 0 2 8660 21d4 lib/vsprintf.o Signed-off-by: Joe Perches <[email protected]> Signed-off-by: David S. Miller <[email protected]>
2009-12-17lib/vsprintf.c: document more vsnprintf extensionsUwe Kleine-König1-1/+12
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 <[email protected]> Cc: Harvey Harrison <[email protected]> Cc: David S. Miller <[email protected]> Cc: Joe Perches <[email protected]> Cc: Jens Rosenboom <[email protected]> Cc: David S. Miller <[email protected]> Cc: Bjorn Helgaas <[email protected]> Cc: Jesse Barnes <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2009-12-15lib/vsprintf.c: add %pU to print UUID/GUIDsJoe Perches1-1/+61
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 <[email protected]> Cc: Jeff Garzik <[email protected]> Cc: Tejun Heo <[email protected]> Cc: Alex Elder <[email protected]> Cc: Christoph Hellwig <[email protected]> Cc: Artem Bityutskiy <[email protected]> Cc: Adrian Hunter <[email protected]> Cc: Steven Whitehouse <[email protected]> Cc: Mauro Carvalho Chehab <[email protected]> Cc: Matt Mackall <[email protected]> Cc: Neil Brown <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2009-12-15tree-wide: convert open calls to remove spaces to skip_spaces() lib functionAndré Goddard Rosa1-11/+4
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 <[email protected]> Cc: Julia Lawall <[email protected]> Cc: Martin Schwidefsky <[email protected]> Cc: Jeff Dike <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: "H. Peter Anvin" <[email protected]> Cc: Richard Purdie <[email protected]> Cc: Neil Brown <[email protected]> Cc: Kyle McMartin <[email protected]> Cc: Henrique de Moraes Holschuh <[email protected]> Cc: David Howells <[email protected]> Cc: <[email protected]> Cc: Samuel Ortiz <[email protected]> Cc: Patrick McHardy <[email protected]> Cc: Takashi Iwai <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2009-12-15vsprintf: reuse almost identical simple_strtoulX() functionsAndré Goddard Rosa1-34/+14
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 <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2009-12-15vsprintf: factor out skip_space code in a separate functionAndré Goddard Rosa1-8/+11
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 <[email protected]> Acked-by: Frederic Weisbecker <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2009-12-15vsprintf: move local vars to block local vars and remove unneeded onesAndré Goddard Rosa1-36/+28
Cleanup by moving variables closer to the scope where they're used in fact. Also, remove unneeded ones. Signed-off-by: André Goddard Rosa <[email protected]> Acked-by: Frederic Weisbecker <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2009-12-15vsprintf: reduce code size by avoiding extra checkAndré Goddard Rosa1-1/+2
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 <[email protected]> Acked-by: Frederic Weisbecker <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2009-12-15vsprintf: use TOLOWER whenever possibleAndré Goddard Rosa1-8/+7
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 <[email protected]> Acked-by: Frederic Weisbecker <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2009-12-15vsprintf: give it some care to please checkpatch.plAndré Goddard Rosa1-86/+98
Most relevant complaints were addressed. Signed-off-by: André Goddard Rosa <[email protected]> Acked-by: Frederic Weisbecker <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2009-12-15vsprintf: pre-calculate final string length for later useAndré Goddard Rosa1-4/+5
Signed-off-by: André Goddard Rosa <[email protected]> Acked-by: Frederic Weisbecker <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2009-12-15vsprintf: factorize "(null)" stringAndré Goddard Rosa1-3/+3
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 <[email protected]> Acked-by: Frederic Weisbecker <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2009-11-04vsprintf: use %pR, %pr instead of %pRt, %pRfBjorn Helgaas1-25/+30
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/441 Signed-off-by: Bjorn Helgaas <[email protected]> Signed-off-by: Jesse Barnes <[email protected]>
2009-11-04vsprintf: add %pRt, %pRf to print struct resource detailsBjorn Helgaas1-7/+44
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 <[email protected]> Signed-off-by: Jesse Barnes <[email protected]>
2009-11-04vsprintf: add %pR support for IRQ and DMA resourcesBjorn Helgaas1-10/+21
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 <[email protected]> Signed-off-by: Jesse Barnes <[email protected]>
2009-11-04vsprintf: fix io/mem resource widthBjorn Helgaas1-2/+2
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 <[email protected]> Signed-off-by: Jesse Barnes <[email protected]>
2009-10-01sscanf(): fix %*s%nAndy Spencer1-1/+1
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 <[email protected]> Acked-by: WANG Cong <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2009-09-24Merge branch 'master' of /home/davem/src/GIT/linux-2.6/David S. Miller1-20/+10
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
2009-09-22lib/vsprintf.c: Avoid possible unaligned accesses in %pI6cJoe Perches1-10/+15
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 <[email protected]> Signed-off-by: David S. Miller <[email protected]>
2009-09-22vsprintf: use WARN_ON_ONCEMarcin Slusarz1-12/+2
Signed-off-by: Marcin Slusarz <[email protected]> Reviewed-by: Frederic Weisbecker <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2009-09-17vsnprintf: remove duplicate comment of vsnprintfSteven Rostedt1-6/+4
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 <[email protected]> Cc: Linus Torvalds <[email protected]> Signed-off-by: Steven Rostedt <[email protected]>
2009-09-17vsprintf: add %ps that is the same as %pS but is like %pfSteven Rostedt1-2/+4
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_timers For PowerPC64, we need to use the direct pointer, and we only have %pS which will produce .run_local_timers+0x4/0x1f This patch creates a %ps that matches the %pf as %pS matches %pF. Cc: Linus Torvalds <[email protected]> Cc: Zhao Lei <[email protected]> Acked-by: Benjamin Herrenschmidt <[email protected]> Signed-off-by: Steven Rostedt <[email protected]>
2009-08-29lib/vsprintf.c: Add "%pI6c" - print pointer as compressed ipv6 addressJoe Perches1-47/+152
Signed-off-by: Joe Perches <[email protected]> Tested-by: Jens Rosenboom <[email protected]> Signed-off-by: David S. Miller <[email protected]>
2009-04-29vsprintf: introduce %pf format specifierFrederic Weisbecker1-6/+13
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 <[email protected]> Acked-by: Mike Frysinger <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Zhaolei <[email protected]> Cc: Tom Zanussi <[email protected]> Cc: Li Zefan <[email protected]> Cc: Andrew Morton <[email protected]> Cc: Steven Rostedt <[email protected]> LKML-Reference: <20090415154817.GC5989@nowhere> Signed-off-by: Ingo Molnar <[email protected]>
2009-04-08printk: add support of hh length modifier for printkZhaolei1-5/+32
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 <[email protected]> Acked-by: Lai Jiangshan <[email protected]> Acked-by: Frederic Weisbecker <[email protected]> Cc: [email protected] Cc: Steven Rostedt <[email protected]> LKML-Reference: <[email protected]> Signed-off-by: Ingo Molnar <[email protected]>
2009-04-08printk: fix wrong format string iter for printkZhaolei1-16/+0
printk("%Q"); Output before patch: %QQ Output after patch: %Q Signed-off-by: Zhao Lei <[email protected]> Acked-by: Lai Jiangshan <[email protected]> Acked-by: Frederic Weisbecker <[email protected]> Cc: [email protected] Cc: Steven Rostedt <[email protected]> LKML-Reference: <[email protected]> Signed-off-by: Ingo Molnar <[email protected]>
2009-03-14vsprintf: unify the format decoding layer for its 3 users, cleanupVegard Nossum1-6/+6
Impact: cleanup Rename FORMAT_TYPE_WITDH to => FORMAT_TYPE_WIDTH Cc: Frederic Weisbecker <[email protected]> Cc: Jeremy Fitzhardinge <[email protected]> Signed-off-by: Ingo Molnar <[email protected]>
2009-03-14fix regression from "vsprintf: unify the format decoding layer for its 3 users"Vegard Nossum1-1/+1
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 <[email protected]> Cc: Frederic Weisbecker <[email protected]> Cc: Linus Torvalds <[email protected]> Signed-off-by: Ingo Molnar <[email protected]>
2009-03-10vsprintf: fix bug in negative value printingFrederic Weisbecker1-7/+6
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 <[email protected]> Signed-off-by: Frederic Weisbecker <[email protected]> Cc: Lai Jiangshan <[email protected]> Cc: Steven Rostedt <[email protected]> Cc: Linus Torvalds <[email protected]> LKML-Reference: <20090309201503.GA5010@nowhere> Signed-off-by: Ingo Molnar <[email protected]>
2009-03-06vsprintf: unify the format decoding layer for its 3 usersFrederic Weisbecker1-431/+541
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 <[email protected]> Cc: Linus Torvalds <[email protected]> Acked-by: Steven Rostedt <[email protected]> LKML-Reference: <[email protected]> Signed-off-by: Ingo Molnar <[email protected]>
2009-03-06vsprintf: add binary printfLai Jiangshan1-0/+442
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 [[email protected]: rebase] Signed-off-by: Lai Jiangshan <[email protected]> Signed-off-by: Frederic Weisbecker <[email protected]> Cc: Linus Torvalds <[email protected]> LKML-Reference: <[email protected]> Signed-off-by: Ingo Molnar <[email protected]>
2009-01-06strict_strto* is not strict enoughPavel Machek1-0/+4
It decodes "\n" as 0, which is bad, because stray echo into backlight will turn your backlight off, etc... Signed-off-by: Pavel Machek <[email protected]> Cc: Yi Yang <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2009-01-03Make %p print '(null)' for NULL pointersLinus Torvalds1-0/+3
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 <[email protected]> Acked-by: Harvey Harrison <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2008-11-25aoe: remove private mac address format functionHarvey Harrison1-0/+3
Add %pm to omit the colons when printing a mac address. Signed-off-by: Harvey Harrison <[email protected]> Signed-off-by: David S. Miller <[email protected]>
2008-11-03printk: ipv4 address digits printed in reverse orderHarvey Harrison1-2/+6
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 <[email protected]> Signed-off-by: David S. Miller <[email protected]>
2008-10-29printk: remove %p6 format specifier, fix up commentsHarvey Harrison1-5/+1
Signed-off-by: Harvey Harrison <[email protected]> Signed-off-by: David S. Miller <[email protected]>
2008-10-29printk: add %I4, %I6, %i4, %i6 format specifiersHarvey Harrison1-0/+31
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 <[email protected]> Signed-off-by: David S. Miller <[email protected]>
2008-10-28printk: add %p6 format specifier for IPv6 addressesHarvey Harrison1-0/+22
Takes a pointer to a IPv6 address and formats it in the usual colon-separated hex format: xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx Each 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 <[email protected]> Signed-off-by: David S. Miller <[email protected]>
2008-10-27printk: add %pM format specifier for MAC addressesHarvey Harrison1-0/+21
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 <[email protected]> Signed-off-by: David S. Miller <[email protected]>
2008-10-20Implement %pR to print struct resource contentLinus Torvalds1-6/+43
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 <[email protected]> Signed-off-by: Benjamin Herrenschmidt <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2008-10-16lib: remove defining macros for strict_strto??Harvey Harrison1-49/+68
Open-code them rather than using defining macros. The function bodies are now next to their kerneldoc comments as a bonus. Add casts to the signed cases as they call into the unsigned versions. Avoids the sparse warnings: lib/vsprintf.c:249:1: warning: incorrect type in argument 3 (different signedness) lib/vsprintf.c:249:1: expected unsigned long *res lib/vsprintf.c:249:1: got long *res lib/vsprintf.c:249:1: warning: incorrect type in argument 3 (different signedness) lib/vsprintf.c:249:1: expected unsigned long *res lib/vsprintf.c:249:1: got long *res lib/vsprintf.c:251:1: warning: incorrect type in argument 3 (different signedness) lib/vsprintf.c:251:1: expected unsigned long long *res lib/vsprintf.c:251:1: got long long *res lib/vsprintf.c:251:1: warning: incorrect type in argument 3 (different signedness) lib/vsprintf.c:251:1: expected unsigned long long *res lib/vsprintf.c:251:1: got long long *res Signed-off-by: Harvey Harrison <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2008-10-16lib: trivial whitespace tidyHarvey Harrison1-17/+9
Remove extra lines before the EXPORT_SYMBOL()s Signed-off-by: Harvey Harrison <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2008-10-16lib: pull base-guessing logic to helper functionHarvey Harrison1-38/+42
The default base is 10 unless there is a leading zero, in which case the base will be guessed as 8. The base will only be guesed as 16 when the string starts with '0x' the third character is a valid hex digit. Signed-off-by: Harvey Harrison <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2008-10-16Add kerneldoc documentation for new printk format extensionsAndi Kleen1-0/+12
Add documentation in kerneldoc for new printk format extensions This patch documents the new %pS/%pF options in printk in kernel doc. Hope I didn't miss any other extension. Signed-off-by: Andi Kleen <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2008-09-09lib: Correct printk %pF to work on all architecturesJames Bottomley1-10/+1
It was introduced by "vsprintf: add support for '%pS' and '%pF' pointer formats" in commit 0fe1ef24f7bd0020f29ffe287dfdb9ead33ca0b2. However, the current way its coded doesn't work on parisc64. For two reasons: 1) parisc isn't in the #ifdef and 2) parisc has a different format for function descriptors Make dereference_function_descriptor() more accommodating by allowing architecture overrides. I put the three overrides (for parisc64, ppc64 and ia64) in arch/kernel/module.c because that's where the kernel internal linker which knows how to deal with function descriptors sits. Signed-off-by: James Bottomley <[email protected]> Acked-by: Benjamin Herrenschmidt <[email protected]> Acked-by: Tony Luck <[email protected]> Acked-by: Kyle McMartin <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2008-08-12lib/vsprintf.c: wrong conversion function usedYi Yang1-1/+1
Fix wrong conversion function used by strict_strtou* Signed-off-by: Yi Yang <[email protected]> Reported-by: Swen Schillig <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2008-07-06vsprintf: add support for '%pS' and '%pF' pointer formatsLinus Torvalds1-1/+40
They print out a pointer in symbolic format, if possible (ie using symbolic KALLSYMS information). The '%pS' format is for regular direct pointers (which can point to data or code and that you find on the stack during backtraces etc), while '%pF' is for C function pointer types. On most architectures, the two mean exactly the same thing, but some architectures use an indirect pointer for C function pointers, where the function pointer points to a function descriptor (which in turn contains the actual pointer to the code). The '%pF' code automatically does the appropriate function descriptor dereference on such architectures. Signed-off-by: Linus Torvalds <[email protected]>