projects
/
linux-2.6-microblaze.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge tag 'fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rusty...
[linux-2.6-microblaze.git]
/
lib
/
string_helpers.c
diff --git
a/lib/string_helpers.c
b/lib/string_helpers.c
index
0d25f7a
..
8f8c441
100644
(file)
--- a/
lib/string_helpers.c
+++ b/
lib/string_helpers.c
@@
-20,12
+20,12
@@
* @len: length of buffer
*
* This function returns a string formatted to 3 significant figures
* @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 f
or
+ *
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"
{
static const char *const units_10[] = {
"B", "kB", "MB", "GB", "TB", "PB", "EB"
@@
-42,7
+42,7
@@
int string_get_size(u64 size, const enum string_size_units units,
[STRING_UNITS_2] = 1024,
};
int i, j;
[STRING_UNITS_2] = 1024,
};
int i, j;
- u
64
remainder = 0, sf_cap;
+ u
32
remainder = 0, sf_cap;
char tmp[8];
tmp[0] = '\0';
char tmp[8];
tmp[0] = '\0';
@@
-59,17
+59,14
@@
int string_get_size(u64 size, const enum string_size_units units,
if (j) {
remainder *= 1000;
if (j) {
remainder *= 1000;
- do_div(remainder, divisor[units]);
- snprintf(tmp, sizeof(tmp), ".%03lld",
- (unsigned long long)remainder);
+ remainder /= divisor[units];
+ snprintf(tmp, sizeof(tmp), ".%03u", remainder);
tmp[j+1] = '\0';
}
}
tmp[j+1] = '\0';
}
}
- snprintf(buf, len, "%
lld%s %s", (unsigned long long
)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);