diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/vsprintf.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/lib/vsprintf.c b/lib/vsprintf.c index 6ff38524ec16..d3023df8477f 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c | |||
@@ -1473,7 +1473,7 @@ EXPORT_SYMBOL(vsnprintf); | |||
1473 | * @args: Arguments for the format string | 1473 | * @args: Arguments for the format string |
1474 | * | 1474 | * |
1475 | * The return value is the number of characters which have been written into | 1475 | * The return value is the number of characters which have been written into |
1476 | * the @buf not including the trailing '\0'. If @size is <= 0 the function | 1476 | * the @buf not including the trailing '\0'. If @size is == 0 the function |
1477 | * returns 0. | 1477 | * returns 0. |
1478 | * | 1478 | * |
1479 | * Call this function if you are already dealing with a va_list. | 1479 | * Call this function if you are already dealing with a va_list. |
@@ -1487,7 +1487,11 @@ int vscnprintf(char *buf, size_t size, const char *fmt, va_list args) | |||
1487 | 1487 | ||
1488 | i = vsnprintf(buf, size, fmt, args); | 1488 | i = vsnprintf(buf, size, fmt, args); |
1489 | 1489 | ||
1490 | return (i >= size) ? (size - 1) : i; | 1490 | if (likely(i < size)) |
1491 | return i; | ||
1492 | if (size != 0) | ||
1493 | return size - 1; | ||
1494 | return 0; | ||
1491 | } | 1495 | } |
1492 | EXPORT_SYMBOL(vscnprintf); | 1496 | EXPORT_SYMBOL(vscnprintf); |
1493 | 1497 | ||
@@ -1535,14 +1539,10 @@ int scnprintf(char *buf, size_t size, const char *fmt, ...) | |||
1535 | int i; | 1539 | int i; |
1536 | 1540 | ||
1537 | va_start(args, fmt); | 1541 | va_start(args, fmt); |
1538 | i = vsnprintf(buf, size, fmt, args); | 1542 | i = vscnprintf(buf, size, fmt, args); |
1539 | va_end(args); | 1543 | va_end(args); |
1540 | 1544 | ||
1541 | if (likely(i < size)) | 1545 | return i; |
1542 | return i; | ||
1543 | if (size != 0) | ||
1544 | return size - 1; | ||
1545 | return 0; | ||
1546 | } | 1546 | } |
1547 | EXPORT_SYMBOL(scnprintf); | 1547 | EXPORT_SYMBOL(scnprintf); |
1548 | 1548 | ||