Author | Jamozed <[email protected]> |
Date | 2020-07-09 10:01:21 |
Commit | fb217a800bdc58afe584f69935f74c60eb4bd5df |
Parent | 9884f2c5d6a8cc12827e9f6dee514095197f14d5 |
crc32: Fix implicit conversion warnings
Diffstat
M | src/crc32.c | | | 8 | ++++---- |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/crc32.c b/src/crc32.c index 11a376a..057538f 100644 --- a/src/crc32.c +++ b/src/crc32.c @@ -1,4 +1,4 @@ -// crc32.c, version 1.0.2 +// crc32.c, version 1.0.3 // OMKOV coreutils crc32 // Copyright (C) 2020, Jakob Wakeling // All rights reserved. @@ -41,7 +41,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE SOFTWARE. #include <stdint.h> #include <stdio.h> -#define VERSION "1.0.2" +#define VERSION "1.0.3" static const uint32_t CRC32[] = { 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, @@ -120,14 +120,14 @@ int main(int ac, char *av[]) { A0 = av[0]; static inline int crc32(const char *file) { char stdbuf[BUFSIZ * 16]; FILE *fi; - register size_t fl = 0; register uint32_t crc = ~0; + register size_t fl = 0; register uint32_t crc = (uint32_t)~0; if (!file || (file[0] == '-' && file[1] == 0)) { fi = stdin; } else if (!(fi = fopen(file, "r"))) { return 1; } for (size_t c; (c = fread(stdbuf, 1, sizeof (stdbuf), fi)); fl += c) { for (register size_t i = 0; i != c; ++i) { - crc = (crc >> 8) ^ CRC32[(crc ^ stdbuf[i]) & 0xFF]; + crc = (crc >> 8) ^ CRC32[(crc ^ (unsigned int)stdbuf[i]) & 0xFF]; } } crc = ~crc;