diff options
author | Rasmus Villemoes <linux@rasmusvillemoes.dk> | 2015-02-12 18:01:45 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2015-02-12 21:54:13 -0500 |
commit | 7eed8fde021b4e169e325e5f50d9f12320668bf2 (patch) | |
tree | 17b2014d7c97facc7def41b76d173f48a81489d5 /lib | |
parent | 43e5b666cf25516b5c27cd10c47d287dc9d1f376 (diff) |
lib/string_helpers.c:string_get_size(): remove redundant prefixes
While commit 3c9f3681d0b4 ("[SCSI] lib: add generic helper to print
sizes rounded to the correct SI range") says that Z and Y are included
in preparation for 128 bit computers, they just waste .text currently.
If and when we get u128, string_get_size needs updating anyway (and ISO
needs to come up with four more prefixes).
Also there's no need to include and test for the NULL sentinel; once we
reach "E" size is at most 18. [The test is also wrong; it should be
units_str[units][i+1]; if we've reached NULL we're already doomed.]
Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Cc: James Bottomley <James.Bottomley@HansenPartnership.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/string_helpers.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/lib/string_helpers.c b/lib/string_helpers.c index 58b78ba57439..0d25f7aa732c 100644 --- a/lib/string_helpers.c +++ b/lib/string_helpers.c | |||
@@ -28,11 +28,10 @@ int string_get_size(u64 size, const enum string_size_units units, | |||
28 | char *buf, int len) | 28 | char *buf, int len) |
29 | { | 29 | { |
30 | static const char *const units_10[] = { | 30 | static const char *const units_10[] = { |
31 | "B", "kB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB", NULL | 31 | "B", "kB", "MB", "GB", "TB", "PB", "EB" |
32 | }; | 32 | }; |
33 | static const char *const units_2[] = { | 33 | static const char *const units_2[] = { |
34 | "B", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB", | 34 | "B", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB" |
35 | NULL | ||
36 | }; | 35 | }; |
37 | static const char *const *const units_str[] = { | 36 | static const char *const *const units_str[] = { |
38 | [STRING_UNITS_10] = units_10, | 37 | [STRING_UNITS_10] = units_10, |
@@ -49,7 +48,7 @@ int string_get_size(u64 size, const enum string_size_units units, | |||
49 | tmp[0] = '\0'; | 48 | tmp[0] = '\0'; |
50 | i = 0; | 49 | i = 0; |
51 | if (size >= divisor[units]) { | 50 | if (size >= divisor[units]) { |
52 | while (size >= divisor[units] && units_str[units][i]) { | 51 | while (size >= divisor[units]) { |
53 | remainder = do_div(size, divisor[units]); | 52 | remainder = do_div(size, divisor[units]); |
54 | i++; | 53 | i++; |
55 | } | 54 | } |