From: Paul Eggert Date: Sat, 3 Aug 2024 06:29:56 +0000 (-0700) Subject: Use ckd_mul, ckd_add in to_octal, to_base256 X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=aca308a778920ed52d00f698ea4a244e0da43992;p=thirdparty%2Ftar.git Use ckd_mul, ckd_add in to_octal, to_base256 * src/create.c (to_octal, to_base256): Simplify. --- diff --git a/src/create.c b/src/create.c index c3d88d6c..e6cf465f 100644 --- a/src/create.c +++ b/src/create.c @@ -145,8 +145,8 @@ to_octal (uintmax_t value, char *where, size_t size) do { - where[--i] = '0' + (v & ((1 << LG_8) - 1)); - v >>= LG_8; + where[--i] = '0' + v % 8; + v /= 8; } while (i); } @@ -190,8 +190,8 @@ to_base256 (bool negative, uintmax_t value, char *where, size_t size) do { - where[--i] = v & ((1 << LG_256) - 1); - v = propagated_sign_bits | (v >> LG_256); + where[--i] = v % 256; + v = propagated_sign_bits | (v / 256); } while (i); }