OSDN Git Service

libstring_helpers.c:string_get_size(): return void
authorRasmus Villemoes <linux@rasmusvillemoes.dk>
Thu, 12 Feb 2015 23:01:50 +0000 (15:01 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Fri, 13 Feb 2015 02:54:13 +0000 (18:54 -0800)
string_get_size() was documented to return an error, but in fact always
returned 0.  Since the output always fits in 9 bytes, just document that
and let callers do what they do now: pass a small stack buffer and ignore
the return value.

Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
include/linux/string_helpers.h
lib/string_helpers.c

index 6eb567a..6575718 100644 (file)
@@ -10,8 +10,8 @@ enum string_size_units {
        STRING_UNITS_2,         /* use binary powers of 2^10 */
 };
 
-int string_get_size(u64 size, enum string_size_units units,
-                   char *buf, int len);
+void string_get_size(u64 size, enum string_size_units units,
+                    char *buf, int len);
 
 #define UNESCAPE_SPACE         0x01
 #define UNESCAPE_OCTAL         0x02
index 2b3757f..8f8c441 100644 (file)
  * @len:       length of buffer
  *
  * This function returns a string formatted to 3 significant figures
- * giving the size in the required units.  Returns 0 on success or
- * error on failure.  @buf is always zero terminated.
+ * giving the size in the required units.  @buf should have room for
+ * at least 9 bytes and will always be zero terminated.
  *
  */
-int string_get_size(u64 size, const enum string_size_units units,
-                   char *buf, int len)
+void string_get_size(u64 size, const enum string_size_units units,
+                    char *buf, int len)
 {
        static const char *const units_10[] = {
                "B", "kB", "MB", "GB", "TB", "PB", "EB"
@@ -67,8 +67,6 @@ int string_get_size(u64 size, const enum string_size_units units,
 
        snprintf(buf, len, "%u%s %s", (u32)size,
                 tmp, units_str[units][i]);
-
-       return 0;
 }
 EXPORT_SYMBOL(string_get_size);