]> git.ipfire.org Git - thirdparty/tar.git/commitdiff
Use ckd_mul, ckd_add in to_octal, to_base256
authorPaul Eggert <eggert@cs.ucla.edu>
Sat, 3 Aug 2024 06:29:56 +0000 (23:29 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Sun, 4 Aug 2024 08:41:43 +0000 (01:41 -0700)
* src/create.c (to_octal, to_base256): Simplify.

src/create.c

index c3d88d6c33e5c08cbb01fa2de29ab3b6e7622ae4..e6cf465f7cbc411609e1e79a51d945b1c19f7dd7 100644 (file)
@@ -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);
 }