diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2008-08-27 21:31:23 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2008-08-27 21:31:23 +0000 |
commit | 8f0e34280342f069cbd026112a7012e5edb356b2 (patch) | |
tree | e24168e425a5f4bb0b806799f0204957e54ec8ba | |
parent | f3d1e213fef45ba2df4090e9cd02217d1ef82f00 (diff) | |
download | busybox-w32-8f0e34280342f069cbd026112a7012e5edb356b2.tar.gz busybox-w32-8f0e34280342f069cbd026112a7012e5edb356b2.tar.bz2 busybox-w32-8f0e34280342f069cbd026112a7012e5edb356b2.zip |
cksum: respect CONFIG_LFS=y. Adds 36 bytes in this case.
-rw-r--r-- | coreutils/cksum.c | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/coreutils/cksum.c b/coreutils/cksum.c index 598718486..546532c3c 100644 --- a/coreutils/cksum.c +++ b/coreutils/cksum.c | |||
@@ -13,7 +13,7 @@ int cksum_main(int argc UNUSED_PARAM, char **argv) | |||
13 | { | 13 | { |
14 | uint32_t *crc32_table = crc32_filltable(NULL, 1); | 14 | uint32_t *crc32_table = crc32_filltable(NULL, 1); |
15 | uint32_t crc; | 15 | uint32_t crc; |
16 | long length, filesize; | 16 | off_t length, filesize; |
17 | int bytes_read; | 17 | int bytes_read; |
18 | uint8_t *cp; | 18 | uint8_t *cp; |
19 | 19 | ||
@@ -44,11 +44,19 @@ int cksum_main(int argc UNUSED_PARAM, char **argv) | |||
44 | 44 | ||
45 | filesize = length; | 45 | filesize = length; |
46 | 46 | ||
47 | for (; length; length >>= 8) | 47 | while (length) { |
48 | crc = (crc << 8) ^ crc32_table[((crc >> 24) ^ length) & 0xff]; | 48 | crc = (crc << 8) ^ crc32_table[(uint8_t)(crc >> 24) ^ (uint8_t)length]; |
49 | crc ^= 0xffffffffL; | 49 | /* must ensure that shift is unsigned! */ |
50 | if (sizeof(length) <= sizeof(unsigned)) | ||
51 | length = (unsigned)length >> 8; | ||
52 | else if (sizeof(length) <= sizeof(unsigned long)) | ||
53 | length = (unsigned long)length >> 8; | ||
54 | else | ||
55 | length = (unsigned long long)length >> 8; | ||
56 | } | ||
57 | crc = ~crc; | ||
50 | 58 | ||
51 | printf((*argv ? "%" PRIu32 " %li %s\n" : "%" PRIu32 " %li\n"), | 59 | printf((*argv ? "%"PRIu32" %"OFF_FMT"i %s\n" : "%"PRIu32" %"OFF_FMT"i\n"), |
52 | crc, filesize, *argv); | 60 | crc, filesize, *argv); |
53 | } while (*argv && *++argv); | 61 | } while (*argv && *++argv); |
54 | 62 | ||