diff options
Diffstat (limited to '')
-rw-r--r-- | libbb/xfuncs.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/libbb/xfuncs.c b/libbb/xfuncs.c index 43ae98065..e8c027f17 100644 --- a/libbb/xfuncs.c +++ b/libbb/xfuncs.c | |||
@@ -59,24 +59,23 @@ char* FAST_FUNC strncpy_IFNAMSIZ(char *dst, const char *src) | |||
59 | * A truncated result contains the first few digits of the result ala strncpy. | 59 | * A truncated result contains the first few digits of the result ala strncpy. |
60 | * Returns a pointer past last generated digit, does _not_ store NUL. | 60 | * Returns a pointer past last generated digit, does _not_ store NUL. |
61 | */ | 61 | */ |
62 | void BUG_sizeof(void); | ||
63 | char* FAST_FUNC utoa_to_buf(unsigned n, char *buf, unsigned buflen) | 62 | char* FAST_FUNC utoa_to_buf(unsigned n, char *buf, unsigned buflen) |
64 | { | 63 | { |
65 | unsigned i, out, res; | 64 | unsigned i, out, res; |
66 | 65 | ||
67 | if (buflen) { | 66 | if (buflen) { |
68 | out = 0; | 67 | out = 0; |
68 | |||
69 | BUILD_BUG_ON(sizeof(n) != 4 && sizeof(n) != 8); | ||
69 | if (sizeof(n) == 4) | 70 | if (sizeof(n) == 4) |
70 | // 2^32-1 = 4294967295 | 71 | // 2^32-1 = 4294967295 |
71 | i = 1000000000; | 72 | i = 1000000000; |
72 | #if UINT_MAX > 4294967295 /* prevents warning about "const too large" */ | 73 | #if UINT_MAX > 0xffffffff /* prevents warning about "const too large" */ |
73 | else | 74 | else |
74 | if (sizeof(n) == 8) | 75 | if (sizeof(n) == 8) |
75 | // 2^64-1 = 18446744073709551615 | 76 | // 2^64-1 = 18446744073709551615 |
76 | i = 10000000000000000000; | 77 | i = 10000000000000000000; |
77 | #endif | 78 | #endif |
78 | else | ||
79 | BUG_sizeof(); | ||
80 | for (; i; i /= 10) { | 79 | for (; i; i /= 10) { |
81 | res = n / i; | 80 | res = n / i; |
82 | n = n % i; | 81 | n = n % i; |