summaryrefslogtreecommitdiff
path: root/libbb/xfuncs.c
diff options
context:
space:
mode:
authorDenys Vlasenko2018-03-28 17:12:56 +0200
committerDenys Vlasenko2018-03-28 17:12:56 +0200
commite4defe826be49b8ef19912ba4cb291bfe9166e0f (patch)
treec22925d5ec279ce799525879edc9f21961b4764a /libbb/xfuncs.c
parent123fdda0a4a838e61c6a7d15c69d3b438136aee0 (diff)
downloadbusybox-e4defe826be49b8ef19912ba4cb291bfe9166e0f.zip
busybox-e4defe826be49b8ef19912ba4cb291bfe9166e0f.tar.gz
libbb: use BUILD_BUG_ON in utoa_to_buf()
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'libbb/xfuncs.c')
-rw-r--r--libbb/xfuncs.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/libbb/xfuncs.c b/libbb/xfuncs.c
index 43ae980..e8c027f 100644
--- a/libbb/xfuncs.c
+++ b/libbb/xfuncs.c
@@ -59,24 +59,23 @@ char* FAST_FUNC strncpy_IFNAMSIZ(char *dst, const char *src)
* A truncated result contains the first few digits of the result ala strncpy.
* Returns a pointer past last generated digit, does _not_ store NUL.
*/
-void BUG_sizeof(void);
char* FAST_FUNC utoa_to_buf(unsigned n, char *buf, unsigned buflen)
{
unsigned i, out, res;
if (buflen) {
out = 0;
+
+ BUILD_BUG_ON(sizeof(n) != 4 && sizeof(n) != 8);
if (sizeof(n) == 4)
// 2^32-1 = 4294967295
i = 1000000000;
-#if UINT_MAX > 4294967295 /* prevents warning about "const too large" */
+#if UINT_MAX > 0xffffffff /* prevents warning about "const too large" */
else
if (sizeof(n) == 8)
// 2^64-1 = 18446744073709551615
i = 10000000000000000000;
#endif
- else
- BUG_sizeof();
for (; i; i /= 10) {
res = n / i;
n = n % i;