diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2010-10-26 20:15:20 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-10-26 20:15:20 -0400 |
| commit | 31453a9764f7e2a72a6e2c502ace586e2663a68c (patch) | |
| tree | 5d4db63de5b4b85d1ffdab4e95a75175a784a10a /lib/vsprintf.c | |
| parent | f9ba5375a8aae4aeea6be15df77e24707a429812 (diff) | |
| parent | 93ed0e2d07b25aff4db1d61bfbcd1e82074c0ad5 (diff) | |
Merge branch 'akpm-incoming-1'
* akpm-incoming-1: (176 commits)
scripts/checkpatch.pl: add check for declaration of pci_device_id
scripts/checkpatch.pl: add warnings for static char that could be static const char
checkpatch: version 0.31
checkpatch: statement/block context analyser should look at sanitised lines
checkpatch: handle EXPORT_SYMBOL for DEVICE_ATTR and similar
checkpatch: clean up structure definition macro handline
checkpatch: update copyright dates
checkpatch: Add additional attribute #defines
checkpatch: check for incorrect permissions
checkpatch: ensure kconfig help checks only apply when we are adding help
checkpatch: simplify and consolidate "missing space after" checks
checkpatch: add check for space after struct, union, and enum
checkpatch: returning errno typically should be negative
checkpatch: handle casts better fixing false categorisation of : as binary
checkpatch: ensure we do not collapse bracketed sections into constants
checkpatch: suggest cleanpatch and cleanfile when appropriate
checkpatch: types may sit on a line on their own
checkpatch: fix regressions in "fix handling of leading spaces"
div64_u64(): improve precision on 32bit platforms
lib/parser: cleanup match_number()
...
Diffstat (limited to 'lib/vsprintf.c')
| -rw-r--r-- | lib/vsprintf.c | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/lib/vsprintf.c b/lib/vsprintf.c index 7af9d841c43b..c150d3dafff4 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c | |||
| @@ -988,8 +988,15 @@ static noinline_for_stack | |||
| 988 | char *pointer(const char *fmt, char *buf, char *end, void *ptr, | 988 | char *pointer(const char *fmt, char *buf, char *end, void *ptr, |
| 989 | struct printf_spec spec) | 989 | struct printf_spec spec) |
| 990 | { | 990 | { |
| 991 | if (!ptr) | 991 | if (!ptr) { |
| 992 | /* | ||
| 993 | * Print (null) with the same width as a pointer so it makes | ||
| 994 | * tabular output look nice. | ||
| 995 | */ | ||
| 996 | if (spec.field_width == -1) | ||
| 997 | spec.field_width = 2 * sizeof(void *); | ||
| 992 | return string(buf, end, "(null)", spec); | 998 | return string(buf, end, "(null)", spec); |
| 999 | } | ||
| 993 | 1000 | ||
| 994 | switch (*fmt) { | 1001 | switch (*fmt) { |
| 995 | case 'F': | 1002 | case 'F': |
| @@ -1031,7 +1038,7 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr, | |||
| 1031 | } | 1038 | } |
| 1032 | spec.flags |= SMALL; | 1039 | spec.flags |= SMALL; |
| 1033 | if (spec.field_width == -1) { | 1040 | if (spec.field_width == -1) { |
| 1034 | spec.field_width = 2*sizeof(void *); | 1041 | spec.field_width = 2 * sizeof(void *); |
| 1035 | spec.flags |= ZEROPAD; | 1042 | spec.flags |= ZEROPAD; |
| 1036 | } | 1043 | } |
| 1037 | spec.base = 16; | 1044 | spec.base = 16; |
| @@ -1497,7 +1504,7 @@ EXPORT_SYMBOL(snprintf); | |||
| 1497 | * @...: Arguments for the format string | 1504 | * @...: Arguments for the format string |
| 1498 | * | 1505 | * |
| 1499 | * The return value is the number of characters written into @buf not including | 1506 | * The return value is the number of characters written into @buf not including |
| 1500 | * the trailing '\0'. If @size is <= 0 the function returns 0. | 1507 | * the trailing '\0'. If @size is == 0 the function returns 0. |
| 1501 | */ | 1508 | */ |
| 1502 | 1509 | ||
| 1503 | int scnprintf(char *buf, size_t size, const char *fmt, ...) | 1510 | int scnprintf(char *buf, size_t size, const char *fmt, ...) |
| @@ -1509,7 +1516,11 @@ int scnprintf(char *buf, size_t size, const char *fmt, ...) | |||
| 1509 | i = vsnprintf(buf, size, fmt, args); | 1516 | i = vsnprintf(buf, size, fmt, args); |
| 1510 | va_end(args); | 1517 | va_end(args); |
| 1511 | 1518 | ||
| 1512 | return (i >= size) ? (size - 1) : i; | 1519 | if (likely(i < size)) |
| 1520 | return i; | ||
| 1521 | if (size != 0) | ||
| 1522 | return size - 1; | ||
| 1523 | return 0; | ||
| 1513 | } | 1524 | } |
| 1514 | EXPORT_SYMBOL(scnprintf); | 1525 | EXPORT_SYMBOL(scnprintf); |
| 1515 | 1526 | ||
