]> bbs.cooldavid.org Git - net-next-2.6.git/blobdiff - lib/vsprintf.c
netfilter: fix IP_VS dependencies
[net-next-2.6.git] / lib / vsprintf.c
index 8378c136b6e15725d73637ddc2aac1251308814a..c150d3dafff4a4152f085ff1ae33ae0f122f25f6 100644 (file)
@@ -1504,7 +1504,7 @@ EXPORT_SYMBOL(snprintf);
  * @...: Arguments for the format string
  *
  * The return value is the number of characters written into @buf not including
- * the trailing '\0'. If @size is <= 0 the function returns 0.
+ * the trailing '\0'. If @size is == 0 the function returns 0.
  */
 
 int scnprintf(char *buf, size_t size, const char *fmt, ...)
@@ -1516,7 +1516,11 @@ int scnprintf(char *buf, size_t size, const char *fmt, ...)
        i = vsnprintf(buf, size, fmt, args);
        va_end(args);
 
-       return (i >= size) ? (size - 1) : i;
+       if (likely(i < size))
+               return i;
+       if (size != 0)
+               return size - 1;
+       return 0;
 }
 EXPORT_SYMBOL(scnprintf);