Commit d1214c65 authored by Rasmus Villemoes's avatar Rasmus Villemoes Committed by Linus Torvalds

libstring_helpers.c:string_get_size(): return void

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: default avatarRasmus Villemoes <linux@rasmusvillemoes.dk>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 84b9fbed
...@@ -10,8 +10,8 @@ enum string_size_units { ...@@ -10,8 +10,8 @@ enum string_size_units {
STRING_UNITS_2, /* use binary powers of 2^10 */ STRING_UNITS_2, /* use binary powers of 2^10 */
}; };
int string_get_size(u64 size, enum string_size_units units, void string_get_size(u64 size, enum string_size_units units,
char *buf, int len); char *buf, int len);
#define UNESCAPE_SPACE 0x01 #define UNESCAPE_SPACE 0x01
#define UNESCAPE_OCTAL 0x02 #define UNESCAPE_OCTAL 0x02
......
...@@ -20,12 +20,12 @@ ...@@ -20,12 +20,12 @@
* @len: length of buffer * @len: length of buffer
* *
* This function returns a string formatted to 3 significant figures * This function returns a string formatted to 3 significant figures
* giving the size in the required units. Returns 0 on success or * giving the size in the required units. @buf should have room for
* error on failure. @buf is always zero terminated. * at least 9 bytes and will always be zero terminated.
* *
*/ */
int string_get_size(u64 size, const enum string_size_units units, void string_get_size(u64 size, const enum string_size_units units,
char *buf, int len) char *buf, int len)
{ {
static const char *const units_10[] = { static const char *const units_10[] = {
"B", "kB", "MB", "GB", "TB", "PB", "EB" "B", "kB", "MB", "GB", "TB", "PB", "EB"
...@@ -67,8 +67,6 @@ int string_get_size(u64 size, const enum string_size_units units, ...@@ -67,8 +67,6 @@ int string_get_size(u64 size, const enum string_size_units units,
snprintf(buf, len, "%u%s %s", (u32)size, snprintf(buf, len, "%u%s %s", (u32)size,
tmp, units_str[units][i]); tmp, units_str[units][i]);
return 0;
} }
EXPORT_SYMBOL(string_get_size); EXPORT_SYMBOL(string_get_size);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment