diff options
author | Rutger Broekhoff | 2023-11-01 16:48:02 +0100 |
---|---|---|
committer | Rutger Broekhoff | 2023-11-01 16:48:02 +0100 |
commit | e33788715ce08f9410290dcea9ca0ddb26692eed (patch) | |
tree | c64bce995bd38f89d855983caf929a98c5ffe825 /src/crc16.zig | |
parent | 04252bac0d7a9383f943337366d6a6631ce44e91 (diff) | |
download | zig-nkeys-e33788715ce08f9410290dcea9ca0ddb26692eed.tar.gz zig-nkeys-e33788715ce08f9410290dcea9ca0ddb26692eed.zip |
Update for Zig 0.11.0
Diffstat (limited to 'src/crc16.zig')
-rw-r--r-- | src/crc16.zig | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/crc16.zig b/src/crc16.zig index 3ea5a15..1257ea2 100644 --- a/src/crc16.zig +++ b/src/crc16.zig | |||
@@ -7,7 +7,7 @@ const crc16tab: [256]u16 = tab: { | |||
7 | const poly: u32 = 0x1021; | 7 | const poly: u32 = 0x1021; |
8 | var table: [256]u16 = undefined; | 8 | var table: [256]u16 = undefined; |
9 | 9 | ||
10 | for (table) |*crc, i| { | 10 | for (&table, 0..) |*crc, i| { |
11 | crc.* = @as(u16, i) << 8; | 11 | crc.* = @as(u16, i) << 8; |
12 | var j = 0; | 12 | var j = 0; |
13 | while (j < 8) : (j += 1) { | 13 | while (j < 8) : (j += 1) { |
@@ -25,7 +25,7 @@ const crc16tab: [256]u16 = tab: { | |||
25 | pub fn update(crc: u16, with_data: []const u8) u16 { | 25 | pub fn update(crc: u16, with_data: []const u8) u16 { |
26 | var new_crc = crc; | 26 | var new_crc = crc; |
27 | for (with_data) |b| { | 27 | for (with_data) |b| { |
28 | new_crc = (new_crc << 8) ^ crc16tab[@truncate(u8, new_crc >> 8) ^ b]; | 28 | new_crc = (new_crc << 8) ^ crc16tab[@as(u8, @truncate(new_crc >> 8)) ^ b]; |
29 | } | 29 | } |
30 | return new_crc; | 30 | return new_crc; |
31 | } | 31 | } |