aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/vsprintf.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/vsprintf.c b/lib/vsprintf.c
index 8378c136b6e1..c150d3dafff4 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -1504,7 +1504,7 @@ EXPORT_SYMBOL(snprintf);
1504 * @...: Arguments for the format string 1504 * @...: Arguments for the format string
1505 * 1505 *
1506 * 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
1507 * the trailing '\0'. If @size is <= 0 the function returns 0. 1507 * the trailing '\0'. If @size is == 0 the function returns 0.
1508 */ 1508 */
1509 1509
1510int scnprintf(char *buf, size_t size, const char *fmt, ...) 1510int scnprintf(char *buf, size_t size, const char *fmt, ...)
@@ -1516,7 +1516,11 @@ int scnprintf(char *buf, size_t size, const char *fmt, ...)
1516 i = vsnprintf(buf, size, fmt, args); 1516 i = vsnprintf(buf, size, fmt, args);
1517 va_end(args); 1517 va_end(args);
1518 1518
1519 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;
1520} 1524}
1521EXPORT_SYMBOL(scnprintf); 1525EXPORT_SYMBOL(scnprintf);
1522 1526