diff options
author | Ingo Molnar <mingo@elte.hu> | 2008-12-31 02:31:57 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-12-31 02:31:57 -0500 |
commit | a9de18eb761f7c1c860964b2e5addc1a35c7e861 (patch) | |
tree | 886e75fdfd09690cd262ca69cb7f5d1d42b48602 /lib/vsprintf.c | |
parent | b2aaf8f74cdc84a9182f6cabf198b7763bcb9d40 (diff) | |
parent | 6a94cb73064c952255336cc57731904174b2c58f (diff) |
Merge branch 'linus' into stackprotector
Conflicts:
arch/x86/include/asm/pda.h
kernel/fork.c
Diffstat (limited to 'lib/vsprintf.c')
-rw-r--r-- | lib/vsprintf.c | 361 |
1 files changed, 251 insertions, 110 deletions
diff --git a/lib/vsprintf.c b/lib/vsprintf.c index c399bc1093cb..3b777025d876 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c | |||
@@ -24,6 +24,7 @@ | |||
24 | #include <linux/kernel.h> | 24 | #include <linux/kernel.h> |
25 | #include <linux/kallsyms.h> | 25 | #include <linux/kallsyms.h> |
26 | #include <linux/uaccess.h> | 26 | #include <linux/uaccess.h> |
27 | #include <linux/ioport.h> | ||
27 | 28 | ||
28 | #include <asm/page.h> /* for PAGE_SIZE */ | 29 | #include <asm/page.h> /* for PAGE_SIZE */ |
29 | #include <asm/div64.h> | 30 | #include <asm/div64.h> |
@@ -32,40 +33,48 @@ | |||
32 | /* Works only for digits and letters, but small and fast */ | 33 | /* Works only for digits and letters, but small and fast */ |
33 | #define TOLOWER(x) ((x) | 0x20) | 34 | #define TOLOWER(x) ((x) | 0x20) |
34 | 35 | ||
36 | static unsigned int simple_guess_base(const char *cp) | ||
37 | { | ||
38 | if (cp[0] == '0') { | ||
39 | if (TOLOWER(cp[1]) == 'x' && isxdigit(cp[2])) | ||
40 | return 16; | ||
41 | else | ||
42 | return 8; | ||
43 | } else { | ||
44 | return 10; | ||
45 | } | ||
46 | } | ||
47 | |||
35 | /** | 48 | /** |
36 | * simple_strtoul - convert a string to an unsigned long | 49 | * simple_strtoul - convert a string to an unsigned long |
37 | * @cp: The start of the string | 50 | * @cp: The start of the string |
38 | * @endp: A pointer to the end of the parsed string will be placed here | 51 | * @endp: A pointer to the end of the parsed string will be placed here |
39 | * @base: The number base to use | 52 | * @base: The number base to use |
40 | */ | 53 | */ |
41 | unsigned long simple_strtoul(const char *cp,char **endp,unsigned int base) | 54 | unsigned long simple_strtoul(const char *cp, char **endp, unsigned int base) |
42 | { | 55 | { |
43 | unsigned long result = 0,value; | 56 | unsigned long result = 0; |
44 | 57 | ||
45 | if (!base) { | 58 | if (!base) |
46 | base = 10; | 59 | base = simple_guess_base(cp); |
47 | if (*cp == '0') { | 60 | |
48 | base = 8; | 61 | if (base == 16 && cp[0] == '0' && TOLOWER(cp[1]) == 'x') |
49 | cp++; | 62 | cp += 2; |
50 | if ((TOLOWER(*cp) == 'x') && isxdigit(cp[1])) { | 63 | |
51 | cp++; | 64 | while (isxdigit(*cp)) { |
52 | base = 16; | 65 | unsigned int value; |
53 | } | 66 | |
54 | } | 67 | value = isdigit(*cp) ? *cp - '0' : TOLOWER(*cp) - 'a' + 10; |
55 | } else if (base == 16) { | 68 | if (value >= base) |
56 | if (cp[0] == '0' && TOLOWER(cp[1]) == 'x') | 69 | break; |
57 | cp += 2; | 70 | result = result * base + value; |
58 | } | ||
59 | while (isxdigit(*cp) && | ||
60 | (value = isdigit(*cp) ? *cp-'0' : TOLOWER(*cp)-'a'+10) < base) { | ||
61 | result = result*base + value; | ||
62 | cp++; | 71 | cp++; |
63 | } | 72 | } |
73 | |||
64 | if (endp) | 74 | if (endp) |
65 | *endp = (char *)cp; | 75 | *endp = (char *)cp; |
66 | return result; | 76 | return result; |
67 | } | 77 | } |
68 | |||
69 | EXPORT_SYMBOL(simple_strtoul); | 78 | EXPORT_SYMBOL(simple_strtoul); |
70 | 79 | ||
71 | /** | 80 | /** |
@@ -74,13 +83,12 @@ EXPORT_SYMBOL(simple_strtoul); | |||
74 | * @endp: A pointer to the end of the parsed string will be placed here | 83 | * @endp: A pointer to the end of the parsed string will be placed here |
75 | * @base: The number base to use | 84 | * @base: The number base to use |
76 | */ | 85 | */ |
77 | long simple_strtol(const char *cp,char **endp,unsigned int base) | 86 | long simple_strtol(const char *cp, char **endp, unsigned int base) |
78 | { | 87 | { |
79 | if(*cp=='-') | 88 | if(*cp == '-') |
80 | return -simple_strtoul(cp+1,endp,base); | 89 | return -simple_strtoul(cp + 1, endp, base); |
81 | return simple_strtoul(cp,endp,base); | 90 | return simple_strtoul(cp, endp, base); |
82 | } | 91 | } |
83 | |||
84 | EXPORT_SYMBOL(simple_strtol); | 92 | EXPORT_SYMBOL(simple_strtol); |
85 | 93 | ||
86 | /** | 94 | /** |
@@ -89,34 +97,30 @@ EXPORT_SYMBOL(simple_strtol); | |||
89 | * @endp: A pointer to the end of the parsed string will be placed here | 97 | * @endp: A pointer to the end of the parsed string will be placed here |
90 | * @base: The number base to use | 98 | * @base: The number base to use |
91 | */ | 99 | */ |
92 | unsigned long long simple_strtoull(const char *cp,char **endp,unsigned int base) | 100 | unsigned long long simple_strtoull(const char *cp, char **endp, unsigned int base) |
93 | { | 101 | { |
94 | unsigned long long result = 0,value; | 102 | unsigned long long result = 0; |
95 | 103 | ||
96 | if (!base) { | 104 | if (!base) |
97 | base = 10; | 105 | base = simple_guess_base(cp); |
98 | if (*cp == '0') { | 106 | |
99 | base = 8; | 107 | if (base == 16 && cp[0] == '0' && TOLOWER(cp[1]) == 'x') |
100 | cp++; | 108 | cp += 2; |
101 | if ((TOLOWER(*cp) == 'x') && isxdigit(cp[1])) { | 109 | |
102 | cp++; | 110 | while (isxdigit(*cp)) { |
103 | base = 16; | 111 | unsigned int value; |
104 | } | 112 | |
105 | } | 113 | value = isdigit(*cp) ? *cp - '0' : TOLOWER(*cp) - 'a' + 10; |
106 | } else if (base == 16) { | 114 | if (value >= base) |
107 | if (cp[0] == '0' && TOLOWER(cp[1]) == 'x') | 115 | break; |
108 | cp += 2; | 116 | result = result * base + value; |
109 | } | ||
110 | while (isxdigit(*cp) | ||
111 | && (value = isdigit(*cp) ? *cp-'0' : TOLOWER(*cp)-'a'+10) < base) { | ||
112 | result = result*base + value; | ||
113 | cp++; | 117 | cp++; |
114 | } | 118 | } |
119 | |||
115 | if (endp) | 120 | if (endp) |
116 | *endp = (char *)cp; | 121 | *endp = (char *)cp; |
117 | return result; | 122 | return result; |
118 | } | 123 | } |
119 | |||
120 | EXPORT_SYMBOL(simple_strtoull); | 124 | EXPORT_SYMBOL(simple_strtoull); |
121 | 125 | ||
122 | /** | 126 | /** |
@@ -125,14 +129,13 @@ EXPORT_SYMBOL(simple_strtoull); | |||
125 | * @endp: A pointer to the end of the parsed string will be placed here | 129 | * @endp: A pointer to the end of the parsed string will be placed here |
126 | * @base: The number base to use | 130 | * @base: The number base to use |
127 | */ | 131 | */ |
128 | long long simple_strtoll(const char *cp,char **endp,unsigned int base) | 132 | long long simple_strtoll(const char *cp, char **endp, unsigned int base) |
129 | { | 133 | { |
130 | if(*cp=='-') | 134 | if(*cp=='-') |
131 | return -simple_strtoull(cp+1,endp,base); | 135 | return -simple_strtoull(cp + 1, endp, base); |
132 | return simple_strtoull(cp,endp,base); | 136 | return simple_strtoull(cp, endp, base); |
133 | } | 137 | } |
134 | 138 | ||
135 | |||
136 | /** | 139 | /** |
137 | * strict_strtoul - convert a string to an unsigned long strictly | 140 | * strict_strtoul - convert a string to an unsigned long strictly |
138 | * @cp: The string to be converted | 141 | * @cp: The string to be converted |
@@ -155,7 +158,27 @@ long long simple_strtoll(const char *cp,char **endp,unsigned int base) | |||
155 | * simple_strtoul just ignores the successive invalid characters and | 158 | * simple_strtoul just ignores the successive invalid characters and |
156 | * return the converted value of prefix part of the string. | 159 | * return the converted value of prefix part of the string. |
157 | */ | 160 | */ |
158 | int strict_strtoul(const char *cp, unsigned int base, unsigned long *res); | 161 | int strict_strtoul(const char *cp, unsigned int base, unsigned long *res) |
162 | { | ||
163 | char *tail; | ||
164 | unsigned long val; | ||
165 | size_t len; | ||
166 | |||
167 | *res = 0; | ||
168 | len = strlen(cp); | ||
169 | if (len == 0) | ||
170 | return -EINVAL; | ||
171 | |||
172 | val = simple_strtoul(cp, &tail, base); | ||
173 | if ((*tail == '\0') || | ||
174 | ((len == (size_t)(tail - cp) + 1) && (*tail == '\n'))) { | ||
175 | *res = val; | ||
176 | return 0; | ||
177 | } | ||
178 | |||
179 | return -EINVAL; | ||
180 | } | ||
181 | EXPORT_SYMBOL(strict_strtoul); | ||
159 | 182 | ||
160 | /** | 183 | /** |
161 | * strict_strtol - convert a string to a long strictly | 184 | * strict_strtol - convert a string to a long strictly |
@@ -169,7 +192,20 @@ int strict_strtoul(const char *cp, unsigned int base, unsigned long *res); | |||
169 | * It returns 0 if conversion is successful and *res is set to the converted | 192 | * It returns 0 if conversion is successful and *res is set to the converted |
170 | * value, otherwise it returns -EINVAL and *res is set to 0. | 193 | * value, otherwise it returns -EINVAL and *res is set to 0. |
171 | */ | 194 | */ |
172 | int strict_strtol(const char *cp, unsigned int base, long *res); | 195 | int strict_strtol(const char *cp, unsigned int base, long *res) |
196 | { | ||
197 | int ret; | ||
198 | if (*cp == '-') { | ||
199 | ret = strict_strtoul(cp + 1, base, (unsigned long *)res); | ||
200 | if (!ret) | ||
201 | *res = -(*res); | ||
202 | } else { | ||
203 | ret = strict_strtoul(cp, base, (unsigned long *)res); | ||
204 | } | ||
205 | |||
206 | return ret; | ||
207 | } | ||
208 | EXPORT_SYMBOL(strict_strtol); | ||
173 | 209 | ||
174 | /** | 210 | /** |
175 | * strict_strtoull - convert a string to an unsigned long long strictly | 211 | * strict_strtoull - convert a string to an unsigned long long strictly |
@@ -193,7 +229,27 @@ int strict_strtol(const char *cp, unsigned int base, long *res); | |||
193 | * simple_strtoull just ignores the successive invalid characters and | 229 | * simple_strtoull just ignores the successive invalid characters and |
194 | * return the converted value of prefix part of the string. | 230 | * return the converted value of prefix part of the string. |
195 | */ | 231 | */ |
196 | int strict_strtoull(const char *cp, unsigned int base, unsigned long long *res); | 232 | int strict_strtoull(const char *cp, unsigned int base, unsigned long long *res) |
233 | { | ||
234 | char *tail; | ||
235 | unsigned long long val; | ||
236 | size_t len; | ||
237 | |||
238 | *res = 0; | ||
239 | len = strlen(cp); | ||
240 | if (len == 0) | ||
241 | return -EINVAL; | ||
242 | |||
243 | val = simple_strtoull(cp, &tail, base); | ||
244 | if ((*tail == '\0') || | ||
245 | ((len == (size_t)(tail - cp) + 1) && (*tail == '\n'))) { | ||
246 | *res = val; | ||
247 | return 0; | ||
248 | } | ||
249 | |||
250 | return -EINVAL; | ||
251 | } | ||
252 | EXPORT_SYMBOL(strict_strtoull); | ||
197 | 253 | ||
198 | /** | 254 | /** |
199 | * strict_strtoll - convert a string to a long long strictly | 255 | * strict_strtoll - convert a string to a long long strictly |
@@ -207,53 +263,20 @@ int strict_strtoull(const char *cp, unsigned int base, unsigned long long *res); | |||
207 | * It returns 0 if conversion is successful and *res is set to the converted | 263 | * It returns 0 if conversion is successful and *res is set to the converted |
208 | * value, otherwise it returns -EINVAL and *res is set to 0. | 264 | * value, otherwise it returns -EINVAL and *res is set to 0. |
209 | */ | 265 | */ |
210 | int strict_strtoll(const char *cp, unsigned int base, long long *res); | 266 | int strict_strtoll(const char *cp, unsigned int base, long long *res) |
211 | 267 | { | |
212 | #define define_strict_strtoux(type, valtype) \ | 268 | int ret; |
213 | int strict_strtou##type(const char *cp, unsigned int base, valtype *res)\ | 269 | if (*cp == '-') { |
214 | { \ | 270 | ret = strict_strtoull(cp + 1, base, (unsigned long long *)res); |
215 | char *tail; \ | 271 | if (!ret) |
216 | valtype val; \ | 272 | *res = -(*res); |
217 | size_t len; \ | 273 | } else { |
218 | \ | 274 | ret = strict_strtoull(cp, base, (unsigned long long *)res); |
219 | *res = 0; \ | 275 | } |
220 | len = strlen(cp); \ | ||
221 | if (len == 0) \ | ||
222 | return -EINVAL; \ | ||
223 | \ | ||
224 | val = simple_strtou##type(cp, &tail, base); \ | ||
225 | if ((*tail == '\0') || \ | ||
226 | ((len == (size_t)(tail - cp) + 1) && (*tail == '\n'))) {\ | ||
227 | *res = val; \ | ||
228 | return 0; \ | ||
229 | } \ | ||
230 | \ | ||
231 | return -EINVAL; \ | ||
232 | } \ | ||
233 | |||
234 | #define define_strict_strtox(type, valtype) \ | ||
235 | int strict_strto##type(const char *cp, unsigned int base, valtype *res) \ | ||
236 | { \ | ||
237 | int ret; \ | ||
238 | if (*cp == '-') { \ | ||
239 | ret = strict_strtou##type(cp+1, base, res); \ | ||
240 | if (!ret) \ | ||
241 | *res = -(*res); \ | ||
242 | } else \ | ||
243 | ret = strict_strtou##type(cp, base, res); \ | ||
244 | \ | ||
245 | return ret; \ | ||
246 | } \ | ||
247 | |||
248 | define_strict_strtoux(l, unsigned long) | ||
249 | define_strict_strtox(l, long) | ||
250 | define_strict_strtoux(ll, unsigned long long) | ||
251 | define_strict_strtox(ll, long long) | ||
252 | 276 | ||
253 | EXPORT_SYMBOL(strict_strtoul); | 277 | return ret; |
254 | EXPORT_SYMBOL(strict_strtol); | 278 | } |
255 | EXPORT_SYMBOL(strict_strtoll); | 279 | EXPORT_SYMBOL(strict_strtoll); |
256 | EXPORT_SYMBOL(strict_strtoull); | ||
257 | 280 | ||
258 | static int skip_atoi(const char **s) | 281 | static int skip_atoi(const char **s) |
259 | { | 282 | { |
@@ -528,18 +551,113 @@ static char *symbol_string(char *buf, char *end, void *ptr, int field_width, int | |||
528 | #endif | 551 | #endif |
529 | } | 552 | } |
530 | 553 | ||
554 | static char *resource_string(char *buf, char *end, struct resource *res, int field_width, int precision, int flags) | ||
555 | { | ||
556 | #ifndef IO_RSRC_PRINTK_SIZE | ||
557 | #define IO_RSRC_PRINTK_SIZE 4 | ||
558 | #endif | ||
559 | |||
560 | #ifndef MEM_RSRC_PRINTK_SIZE | ||
561 | #define MEM_RSRC_PRINTK_SIZE 8 | ||
562 | #endif | ||
563 | |||
564 | /* room for the actual numbers, the two "0x", -, [, ] and the final zero */ | ||
565 | char sym[4*sizeof(resource_size_t) + 8]; | ||
566 | char *p = sym, *pend = sym + sizeof(sym); | ||
567 | int size = -1; | ||
568 | |||
569 | if (res->flags & IORESOURCE_IO) | ||
570 | size = IO_RSRC_PRINTK_SIZE; | ||
571 | else if (res->flags & IORESOURCE_MEM) | ||
572 | size = MEM_RSRC_PRINTK_SIZE; | ||
573 | |||
574 | *p++ = '['; | ||
575 | p = number(p, pend, res->start, 16, size, -1, SPECIAL | SMALL | ZEROPAD); | ||
576 | *p++ = '-'; | ||
577 | p = number(p, pend, res->end, 16, size, -1, SPECIAL | SMALL | ZEROPAD); | ||
578 | *p++ = ']'; | ||
579 | *p = 0; | ||
580 | |||
581 | return string(buf, end, sym, field_width, precision, flags); | ||
582 | } | ||
583 | |||
584 | static char *mac_address_string(char *buf, char *end, u8 *addr, int field_width, | ||
585 | int precision, int flags) | ||
586 | { | ||
587 | char mac_addr[6 * 3]; /* (6 * 2 hex digits), 5 colons and trailing zero */ | ||
588 | char *p = mac_addr; | ||
589 | int i; | ||
590 | |||
591 | for (i = 0; i < 6; i++) { | ||
592 | p = pack_hex_byte(p, addr[i]); | ||
593 | if (!(flags & SPECIAL) && i != 5) | ||
594 | *p++ = ':'; | ||
595 | } | ||
596 | *p = '\0'; | ||
597 | |||
598 | return string(buf, end, mac_addr, field_width, precision, flags & ~SPECIAL); | ||
599 | } | ||
600 | |||
601 | static char *ip6_addr_string(char *buf, char *end, u8 *addr, int field_width, | ||
602 | int precision, int flags) | ||
603 | { | ||
604 | char ip6_addr[8 * 5]; /* (8 * 4 hex digits), 7 colons and trailing zero */ | ||
605 | char *p = ip6_addr; | ||
606 | int i; | ||
607 | |||
608 | for (i = 0; i < 8; i++) { | ||
609 | p = pack_hex_byte(p, addr[2 * i]); | ||
610 | p = pack_hex_byte(p, addr[2 * i + 1]); | ||
611 | if (!(flags & SPECIAL) && i != 7) | ||
612 | *p++ = ':'; | ||
613 | } | ||
614 | *p = '\0'; | ||
615 | |||
616 | return string(buf, end, ip6_addr, field_width, precision, flags & ~SPECIAL); | ||
617 | } | ||
618 | |||
619 | static char *ip4_addr_string(char *buf, char *end, u8 *addr, int field_width, | ||
620 | int precision, int flags) | ||
621 | { | ||
622 | char ip4_addr[4 * 4]; /* (4 * 3 decimal digits), 3 dots and trailing zero */ | ||
623 | char temp[3]; /* hold each IP quad in reverse order */ | ||
624 | char *p = ip4_addr; | ||
625 | int i, digits; | ||
626 | |||
627 | for (i = 0; i < 4; i++) { | ||
628 | digits = put_dec_trunc(temp, addr[i]) - temp; | ||
629 | /* reverse the digits in the quad */ | ||
630 | while (digits--) | ||
631 | *p++ = temp[digits]; | ||
632 | if (i != 3) | ||
633 | *p++ = '.'; | ||
634 | } | ||
635 | *p = '\0'; | ||
636 | |||
637 | return string(buf, end, ip4_addr, field_width, precision, flags & ~SPECIAL); | ||
638 | } | ||
639 | |||
531 | /* | 640 | /* |
532 | * Show a '%p' thing. A kernel extension is that the '%p' is followed | 641 | * Show a '%p' thing. A kernel extension is that the '%p' is followed |
533 | * by an extra set of alphanumeric characters that are extended format | 642 | * by an extra set of alphanumeric characters that are extended format |
534 | * specifiers. | 643 | * specifiers. |
535 | * | 644 | * |
536 | * Right now we just handle 'F' (for symbolic Function descriptor pointers) | 645 | * Right now we handle: |
537 | * and 'S' (for Symbolic direct pointers), but this can easily be | 646 | * |
538 | * extended in the future (network address types etc). | 647 | * - 'F' For symbolic function descriptor pointers |
648 | * - 'S' For symbolic direct pointers | ||
649 | * - 'R' For a struct resource pointer, it prints the range of | ||
650 | * addresses (not the name nor the flags) | ||
651 | * - 'M' For a 6-byte MAC address, it prints the address in the | ||
652 | * usual colon-separated hex notation | ||
653 | * - 'I' [46] for IPv4/IPv6 addresses printed in the usual way (dot-separated | ||
654 | * decimal for v4 and colon separated network-order 16 bit hex for v6) | ||
655 | * - 'i' [46] for 'raw' IPv4/IPv6 addresses, IPv6 omits the colons, IPv4 is | ||
656 | * currently the same | ||
539 | * | 657 | * |
540 | * The difference between 'S' and 'F' is that on ia64 and ppc64 function | 658 | * Note: The difference between 'S' and 'F' is that on ia64 and ppc64 |
541 | * pointers are really function descriptors, which contain a pointer the | 659 | * function pointers are really function descriptors, which contain a |
542 | * real address. | 660 | * pointer to the real address. |
543 | */ | 661 | */ |
544 | static char *pointer(const char *fmt, char *buf, char *end, void *ptr, int field_width, int precision, int flags) | 662 | static char *pointer(const char *fmt, char *buf, char *end, void *ptr, int field_width, int precision, int flags) |
545 | { | 663 | { |
@@ -549,6 +667,23 @@ static char *pointer(const char *fmt, char *buf, char *end, void *ptr, int field | |||
549 | /* Fallthrough */ | 667 | /* Fallthrough */ |
550 | case 'S': | 668 | case 'S': |
551 | return symbol_string(buf, end, ptr, field_width, precision, flags); | 669 | return symbol_string(buf, end, ptr, field_width, precision, flags); |
670 | case 'R': | ||
671 | return resource_string(buf, end, ptr, field_width, precision, flags); | ||
672 | case 'm': | ||
673 | flags |= SPECIAL; | ||
674 | /* Fallthrough */ | ||
675 | case 'M': | ||
676 | return mac_address_string(buf, end, ptr, field_width, precision, flags); | ||
677 | case 'i': | ||
678 | flags |= SPECIAL; | ||
679 | /* Fallthrough */ | ||
680 | case 'I': | ||
681 | if (fmt[1] == '6') | ||
682 | return ip6_addr_string(buf, end, ptr, field_width, precision, flags); | ||
683 | if (fmt[1] == '4') | ||
684 | return ip4_addr_string(buf, end, ptr, field_width, precision, flags); | ||
685 | flags &= ~SPECIAL; | ||
686 | break; | ||
552 | } | 687 | } |
553 | flags |= SMALL; | 688 | flags |= SMALL; |
554 | if (field_width == -1) { | 689 | if (field_width == -1) { |
@@ -565,6 +700,11 @@ static char *pointer(const char *fmt, char *buf, char *end, void *ptr, int field | |||
565 | * @fmt: The format string to use | 700 | * @fmt: The format string to use |
566 | * @args: Arguments for the format string | 701 | * @args: Arguments for the format string |
567 | * | 702 | * |
703 | * This function follows C99 vsnprintf, but has some extensions: | ||
704 | * %pS output the name of a text symbol | ||
705 | * %pF output the name of a function pointer | ||
706 | * %pR output the address range in a struct resource | ||
707 | * | ||
568 | * The return value is the number of characters which would | 708 | * The return value is the number of characters which would |
569 | * be generated for the given input, excluding the trailing | 709 | * be generated for the given input, excluding the trailing |
570 | * '\0', as per ISO C99. If you want to have the exact | 710 | * '\0', as per ISO C99. If you want to have the exact |
@@ -790,7 +930,6 @@ int vsnprintf(char *buf, size_t size, const char *fmt, va_list args) | |||
790 | /* the trailing null byte doesn't count towards the total */ | 930 | /* the trailing null byte doesn't count towards the total */ |
791 | return str-buf; | 931 | return str-buf; |
792 | } | 932 | } |
793 | |||
794 | EXPORT_SYMBOL(vsnprintf); | 933 | EXPORT_SYMBOL(vsnprintf); |
795 | 934 | ||
796 | /** | 935 | /** |
@@ -806,6 +945,8 @@ EXPORT_SYMBOL(vsnprintf); | |||
806 | * | 945 | * |
807 | * Call this function if you are already dealing with a va_list. | 946 | * Call this function if you are already dealing with a va_list. |
808 | * You probably want scnprintf() instead. | 947 | * You probably want scnprintf() instead. |
948 | * | ||
949 | * See the vsnprintf() documentation for format string extensions over C99. | ||
809 | */ | 950 | */ |
810 | int vscnprintf(char *buf, size_t size, const char *fmt, va_list args) | 951 | int vscnprintf(char *buf, size_t size, const char *fmt, va_list args) |
811 | { | 952 | { |
@@ -814,7 +955,6 @@ int vscnprintf(char *buf, size_t size, const char *fmt, va_list args) | |||
814 | i=vsnprintf(buf,size,fmt,args); | 955 | i=vsnprintf(buf,size,fmt,args); |
815 | return (i >= size) ? (size - 1) : i; | 956 | return (i >= size) ? (size - 1) : i; |
816 | } | 957 | } |
817 | |||
818 | EXPORT_SYMBOL(vscnprintf); | 958 | EXPORT_SYMBOL(vscnprintf); |
819 | 959 | ||
820 | /** | 960 | /** |
@@ -828,6 +968,8 @@ EXPORT_SYMBOL(vscnprintf); | |||
828 | * generated for the given input, excluding the trailing null, | 968 | * generated for the given input, excluding the trailing null, |
829 | * as per ISO C99. If the return is greater than or equal to | 969 | * as per ISO C99. If the return is greater than or equal to |
830 | * @size, the resulting string is truncated. | 970 | * @size, the resulting string is truncated. |
971 | * | ||
972 | * See the vsnprintf() documentation for format string extensions over C99. | ||
831 | */ | 973 | */ |
832 | int snprintf(char * buf, size_t size, const char *fmt, ...) | 974 | int snprintf(char * buf, size_t size, const char *fmt, ...) |
833 | { | 975 | { |
@@ -839,7 +981,6 @@ int snprintf(char * buf, size_t size, const char *fmt, ...) | |||
839 | va_end(args); | 981 | va_end(args); |
840 | return i; | 982 | return i; |
841 | } | 983 | } |
842 | |||
843 | EXPORT_SYMBOL(snprintf); | 984 | EXPORT_SYMBOL(snprintf); |
844 | 985 | ||
845 | /** | 986 | /** |
@@ -877,12 +1018,13 @@ EXPORT_SYMBOL(scnprintf); | |||
877 | * | 1018 | * |
878 | * Call this function if you are already dealing with a va_list. | 1019 | * Call this function if you are already dealing with a va_list. |
879 | * You probably want sprintf() instead. | 1020 | * You probably want sprintf() instead. |
1021 | * | ||
1022 | * See the vsnprintf() documentation for format string extensions over C99. | ||
880 | */ | 1023 | */ |
881 | int vsprintf(char *buf, const char *fmt, va_list args) | 1024 | int vsprintf(char *buf, const char *fmt, va_list args) |
882 | { | 1025 | { |
883 | return vsnprintf(buf, INT_MAX, fmt, args); | 1026 | return vsnprintf(buf, INT_MAX, fmt, args); |
884 | } | 1027 | } |
885 | |||
886 | EXPORT_SYMBOL(vsprintf); | 1028 | EXPORT_SYMBOL(vsprintf); |
887 | 1029 | ||
888 | /** | 1030 | /** |
@@ -894,6 +1036,8 @@ EXPORT_SYMBOL(vsprintf); | |||
894 | * The function returns the number of characters written | 1036 | * The function returns the number of characters written |
895 | * into @buf. Use snprintf() or scnprintf() in order to avoid | 1037 | * into @buf. Use snprintf() or scnprintf() in order to avoid |
896 | * buffer overflows. | 1038 | * buffer overflows. |
1039 | * | ||
1040 | * See the vsnprintf() documentation for format string extensions over C99. | ||
897 | */ | 1041 | */ |
898 | int sprintf(char * buf, const char *fmt, ...) | 1042 | int sprintf(char * buf, const char *fmt, ...) |
899 | { | 1043 | { |
@@ -905,7 +1049,6 @@ int sprintf(char * buf, const char *fmt, ...) | |||
905 | va_end(args); | 1049 | va_end(args); |
906 | return i; | 1050 | return i; |
907 | } | 1051 | } |
908 | |||
909 | EXPORT_SYMBOL(sprintf); | 1052 | EXPORT_SYMBOL(sprintf); |
910 | 1053 | ||
911 | /** | 1054 | /** |
@@ -1134,7 +1277,6 @@ int vsscanf(const char * buf, const char * fmt, va_list args) | |||
1134 | 1277 | ||
1135 | return num; | 1278 | return num; |
1136 | } | 1279 | } |
1137 | |||
1138 | EXPORT_SYMBOL(vsscanf); | 1280 | EXPORT_SYMBOL(vsscanf); |
1139 | 1281 | ||
1140 | /** | 1282 | /** |
@@ -1153,5 +1295,4 @@ int sscanf(const char * buf, const char * fmt, ...) | |||
1153 | va_end(args); | 1295 | va_end(args); |
1154 | return i; | 1296 | return i; |
1155 | } | 1297 | } |
1156 | |||
1157 | EXPORT_SYMBOL(sscanf); | 1298 | EXPORT_SYMBOL(sscanf); |